Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Update location after clearing target coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Jan 27, 2016
1 parent 8a23bdc commit a5283b5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3127,11 +3127,13 @@ - (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate animated:(B
|| targetCoordinate.longitude != self.targetCoordinate.longitude)
{
_targetCoordinate = targetCoordinate;
if (CLLocationCoordinate2DIsValid(targetCoordinate)
&& self.userTrackingMode == MGLUserTrackingModeFollowWithCourse
&& self.userLocation.location)
if (self.userTrackingMode == MGLUserTrackingModeFollowWithCourse)
{
[self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated];
self.userTrackingState = MGLUserTrackingStatePossible;
if (self.userLocation.location)
{
[self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated];
}
}
}
}
Expand Down Expand Up @@ -3191,11 +3193,13 @@ - (void)didUpdateLocationWithUserTrackingAnimated:(BOOL)animated
}

if (self.userTrackingMode == MGLUserTrackingModeFollowWithCourse
&& self.userTrackingState != MGLUserTrackingStateBegan
&& CLLocationCoordinate2DIsValid(self.targetCoordinate))
{
// Keep both the user and the destination in view.
[self didUpdateLocationWithTargetAnimated:animated];
if (self.userTrackingState != MGLUserTrackingStateBegan)
{
// Keep both the user and the destination in view.
[self didUpdateLocationWithTargetAnimated:animated];
}
}
else if (self.userTrackingState == MGLUserTrackingStatePossible)
{
Expand Down Expand Up @@ -3260,7 +3264,7 @@ - (void)didUpdateLocationWithTargetAnimated:(BOOL)animated
{
BOOL firstUpdate = self.userTrackingState == MGLUserTrackingStatePossible;
void (^completion)(void);
if (firstUpdate)
if (animated && firstUpdate)
{
self.userTrackingState = MGLUserTrackingStateBegan;
__weak MGLMapView *weakSelf = self;
Expand Down

0 comments on commit a5283b5

Please sign in to comment.