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 17:28:14 -0400
commit87348234d16915176fab313f0d3f2dae246216d9 (patch)
tree95f174ff694b52c6933460014399314e2a3211c9
parentc8dc77f06fa58112797bf1ae21fe8578512dc317 (diff)
downloadqtlocation-mapboxgl-87348234d16915176fab313f0d3f2dae246216d9.tar.gz
[ios] Guard against nil user location when setting tracking mode
-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];
}
}
}