Mapbox / route-me : user location no longer working

309 views Asked by At

I'm using route-me (Alpstein fork) to show a map with user's location. It was working until I updated both Xcode and route-me recently. Now if I set :

mapView.showsUserLocation = YES;
mapView.userTrackingMode = RMUserTrackingModeFollowWithHeading;

Nothing happens. I downloaded the Mapbox-me project (https://github.com/mapbox/mapbox-me) to test if it is working with Mapbox, and it's not. I'm using the simulator for testing. The user location in iOS's Maps app is working, so the simulator seems to be able to send a position.

Is anyone facing the problem ?

1

There are 1 answers

0
Tim Autin On

Well, I was not looking in the good direction, the problem was absolutely not related to MapBox / route-me but to iOS 8 ...

To receive any location update we now need to add one of the following entries in the .plist :

  • NSLocationAlwaysUsageDescription (if your app needs location even in background)
  • NSLocationWhenInUseUsageDescription (if your app only need location when in foreground)

And we need to gently ask the user's permission by doing one of these calls (before asking MapView to display the user's position) :

if([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) [_locationManager requestAlwaysAuthorization];
if([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) [_locationManager requestWhenInUseAuthorization];

If you don't, you will get no error, no warning - and no location update... I definitely love Android development !