summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-07-31 15:24:08 -0700
committerFabian Guerra Soto <fabian.guerra@mapbox.com>2018-08-01 10:21:34 -0700
commit62fb7e1987a3e6a0f04cb10cc57abf22f7b75081 (patch)
treee18fa05b8b0eae3d55884aa4fec36aea825e6e42
parentd6c602b48ccb2d38c4556bee9b5a4335a934aa5f (diff)
downloadqtlocation-mapboxgl-62fb7e1987a3e6a0f04cb10cc57abf22f7b75081.tar.gz
[ios] Fix location manager null reset.
-rw-r--r--platform/ios/src/MGLMapView.h5
-rw-r--r--platform/ios/src/MGLMapView.mm25
2 files changed, 15 insertions, 15 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index e1520401a7..ddc8be23f0 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -333,9 +333,8 @@ MGL_EXPORT IB_DESIGNABLE
To receive the current user location, implement the `-[MGLMapViewDelegate mapView:didUpdateUserLocation:]`
and `-[MGLMapViewDelegate mapView:didFailToLocateUserWithError:]` methods.
- If setting this property to `nil` and setting `showsUserLocation` to `YES`, or
- if no custom manager is provided this property is set to the default
- location manager.
+ If setting this property to `nil` or if no custom manager is provided this property
+ is set to the default location manager.
`MGLMapView` uses a default location manager. If you want to substitute your own
location manager, you should do so by setting this property before setting
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 918506067c..f772432eb7 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -442,6 +442,9 @@ public:
_isWaitingForRedundantReachableNotification = YES;
}
[_reachability startNotifier];
+
+ // setup default location manager
+ self.locationManager = nil;
// Set up annotation management and selection state.
_annotationImagesByIdentifier = [NSMutableDictionary dictionary];
@@ -701,8 +704,10 @@ public:
[self.attributionButtonConstraints removeAllObjects];
self.attributionButtonConstraints = nil;
- self.locationManager.delegate = nil;
- self.locationManager = nil;
+ [_locationManager stopUpdatingLocation];
+ [_locationManager stopUpdatingHeading];
+ _locationManager.delegate = nil;
+
}
- (void)setDelegate:(nullable id<MGLMapViewDelegate>)delegate
@@ -4739,13 +4744,15 @@ public:
#pragma mark - User Location -
-- (void)setLocationManager:(id<MGLLocationManager>)locationManager
+- (void)setLocationManager:(nullable id<MGLLocationManager>)locationManager
{
if (!locationManager) {
- [self.locationManager stopUpdatingLocation];
- [self.locationManager stopUpdatingHeading];
+ locationManager = [[MGLCLLocationManager alloc] init];
}
- self.locationManager.delegate = nil;
+ [_locationManager stopUpdatingLocation];
+ [_locationManager stopUpdatingHeading];
+ _locationManager.delegate = nil;
+
_locationManager = locationManager;
_locationManager.delegate = self;
}
@@ -4756,11 +4763,6 @@ public:
if (shouldEnableLocationServices)
{
- // If no custom location manager is provided will use the internal implementation.
- if (!self.locationManager) {
- self.locationManager = [[MGLCLLocationManager alloc] init];
- }
-
if (self.locationManager.authorizationStatus == kCLAuthorizationStatusNotDetermined)
{
BOOL requiresWhenInUseUsageDescription = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){11,0,0}];
@@ -4792,7 +4794,6 @@ public:
}
}
- self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
[self validateUserHeadingUpdating];