User location not showing after turning device location service on
When device location service is off, a user opens my app that is using Mapbox and Mapbox Navigation SDK. The user can't see its device location on the map because location service is off. When the user goes to the device Settings and turns location service on and then comes back to the app, user location is still invisible. When I check the user location coordinate by mapView.userLocation.coordinate, I get an invalid coordinate. Also the below delegate method not be called even when I call locationManager.startUpdatingLocation():
func mapView(_ mapView: MGLMapView, didUpdate userLocation: MGLUserLocation?)
I can solve the issue by removing old map view and set up a new map view. It means when the user comes back to the app after going to Settings and turning location service to on, I have to remove the old map view and set up another one to show user location. But I don't want to do that.
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse || status == .authorizedAlways {
if mapView != nil {
mapView.removeFromSuperview()
mapView = nil
}
resetupMapView()
}
}
How can I show the user location on map view after turning location service on? Is there any way to reload map view?
Mapbox Navigation SDK version:0.25
To me it seems what needs to happen is that NavigationService needs to implement the didChangeAuthorization delegate method, and if authorization changed positively and NavigationService's start method has been called, we should call startUpdatingHeading() and startUpdatingLocation on nativeLocationSource inside NavigationService.swift. If this sounds good I can make a pull request with this change.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Stale.