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?
Xamarin. Essentials provides a single cross-platform API that works with any iOS, Android, or UWP application that can be accessed from shared code no matter how the user interface is created. See the platform & feature support guide for more information on supported operating systems.
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 locator = CrossGeolocator.Current; var position = await locator.GetPositionAsync(10000); map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position. Longitude), Distance.FromMiles(1)));
Updated: Xamarin Forms now includes by default Xamarin.Essentials: Geolocation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With