From a93e7d7baa285ab950b216079726d1c38709e3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 17 Jan 2016 23:01:56 -0800 Subject: [PATCH] [ios] Non-animated user tracking mode changes Calling -setUserTrackingMode:animated: with animated set to NO should jump instantaneously to the first reported location. --- platform/ios/src/MGLMapView.mm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 38f6d2ec6..079e5a843 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2996,7 +2996,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) if (self.userLocationAnnotationView) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location]]; + [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; } break; @@ -3013,7 +3013,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) if (self.userLocationAnnotationView) { - [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location]]; + [self locationManager:self.locationManager didUpdateLocations:@[self.userLocation.location] animated:animated]; } [self updateHeadingForDeviceOrientation]; @@ -3030,7 +3030,12 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) } } -- (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations:(NSArray *)locations +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations +{ + [self locationManager:manager didUpdateLocations:locations animated:YES]; +} + +- (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations:(NSArray *)locations animated:(BOOL)animated { CLLocation *oldLocation = self.userLocation.location; CLLocation *newLocation = locations.lastObject; @@ -3080,7 +3085,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) edgePadding:insets zoomLevel:self.zoomLevel direction:course - duration:1 + duration:animated ? 1 : 0 animationTimingFunction:linearFunction completionHandler:NULL]; } @@ -3095,7 +3100,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) camera.heading = course; __weak MGLMapView *weakSelf = self; - [self _flyToCamera:camera withDuration:-1 peakAltitude:-1 completionHandler:^{ + [self _flyToCamera:camera withDuration:animated ? -1 : 0 peakAltitude:-1 completionHandler:^{ MGLMapView *strongSelf = weakSelf; strongSelf.userTrackingState = MGLUserTrackingStateChanged; }]; @@ -3113,7 +3118,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) camera.altitude = newLocation.horizontalAccuracy; __weak MGLMapView *weakSelf = self; - [self _flyToCamera:camera withDuration:-1 peakAltitude:-1 completionHandler:^{ + [self _flyToCamera:camera withDuration:animated ? -1 : 0 peakAltitude:-1 completionHandler:^{ MGLMapView *strongSelf = weakSelf; strongSelf.userTrackingState = MGLUserTrackingStateChanged; }];