From 87348234d16915176fab313f0d3f2dae246216d9 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 30 Aug 2017 12:34:21 -0400 Subject: [ios] Guard against nil user location when setting tracking mode --- platform/ios/src/MGLMapView.mm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index af7122fc14..320c4bcda8 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4338,12 +4338,6 @@ public: [self.locationManager stopUpdatingHeading]; - CLLocation *location = self.userLocation.location; - if (location && self.userLocationAnnotationView) - { - [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; - } - break; } case MGLUserTrackingModeFollowWithHeading: @@ -4360,11 +4354,6 @@ public: [self setZoomLevel:self.currentMinimumZoom animated:YES]; } - if (self.userLocationAnnotationView) - { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; - } - [self updateHeadingForDeviceOrientation]; [self.locationManager startUpdatingHeading]; @@ -4373,6 +4362,15 @@ public: } } + if (_userTrackingMode != MGLUserTrackingModeNone) + { + CLLocation *location = self.userLocation.location; + if (location && self.userLocationAnnotationView) + { + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; + } + } + if ([self.delegate respondsToSelector:@selector(mapView:didChangeUserTrackingMode:animated:)]) { [self.delegate mapView:self didChangeUserTrackingMode:_userTrackingMode animated:animated]; @@ -4411,9 +4409,11 @@ public: if (self.userTrackingMode == MGLUserTrackingModeFollowWithCourse) { self.userTrackingState = MGLUserTrackingStatePossible; - if (self.userLocation.location) + + CLLocation *location = self.userLocation.location; + if (location) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; + [self locationManager:self.locationManager didUpdateLocations:@[location] animated:animated]; } } } -- cgit v1.2.1