DarkW1nter
DarkW1nter

Reputation: 2861

Xamarin Forms Maps - showing current location on iOS

In Xamarin Forms, does the IsShowingUser property of Xamarin.Forms.Maps work for iOS?

I can get every aspect of my map to work on both Android and iOS, but the current location 'blue dot' does not show on iOS.

I'm setting this in shared code in the PCL project, just after successfully asking for permission to use location.

var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
            if (status != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });
                status = results[Permission.Location];
            }

            if (status == PermissionStatus.Granted)
            {
                MyMap.IsShowingUser = true;
            }

thanks

Upvotes: 0

Views: 2198

Answers (1)

ColeX
ColeX

Reputation: 14463

I can get every aspect of my map to work on both Android and iOS, but the current location 'blue dot' does not show on iOS.

It is because the map doesn't locate the current user location at that time, you can use Xam.Plugin.Geolocator to get your current location, and move the map to it.

var locator = CrossGeolocator.Current;
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10));
map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position.Longitude),
                                                     Distance.FromMiles(1)));

Upvotes: 2

Related Questions