Matt Matt - 3 months ago 302
C# Question

How to get current location or move to current location in Xamarin.Forms.Map

Since the Map already shows the user location (with IsShowingUser) I just want to zoom to this location. Is this easily possible or do I need to get the location on every platform, since I don't find any GeoLocation object. Only the GeoCoder...
Is this not a common usecase to zoom to users position?

Answer

You will need to call MoveToRegion method with the position you are interested in.

You can use Geolocator Plugin for Xamarin to get the location in PCL project:

var position = await locator.GetPositionAsync(10000);
map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position. Longitude), 
                                             Distance.FromMiles(1))