[ios] Guard against nil user location when setting tracking mode

This commit is contained in:
Jason Wray
2017-08-30 12:34:21 -04:00
parent c8dc77f06f
commit 87348234d1

View File

@@ -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];
}
}
}