summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2017-08-30 12:34:21 -0400
committerJason Wray <jason@mapbox.com>2017-08-30 12:40:34 -0400
commitdf0ea346a5984516aaa1972ac70b5a2be19f1dd7 (patch)
tree72857de8abd3e4e8a99690fd6d74b8ea1e07aba7
parenteedd90961168037954e534507f632fac7cb0a8ae (diff)
downloadqtlocation-mapboxgl-upstream/fb-nil-location-exception.tar.gz
[ios] Guard against nil user location when setting tracking modeupstream/fb-nil-location-exception
-rw-r--r--platform/ios/src/MGLMapView.mm26
1 files 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];
}
}
}