summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
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 /platform/ios/src/MGLMapView.mm
parentd6c602b48ccb2d38c4556bee9b5a4335a934aa5f (diff)
downloadqtlocation-mapboxgl-62fb7e1987a3e6a0f04cb10cc57abf22f7b75081.tar.gz
[ios] Fix location manager null reset.
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm25
1 files changed, 13 insertions, 12 deletions
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];