From 8cdd02bc8fac9f6bd63b8b943119ebdb6f480ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 28 Jan 2016 16:12:11 -0800 Subject: [PATCH] =?UTF-8?q?[ios]=20Eliminated=20=E2=80=9Cflashlight=20mode?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid resetting user tracking state when going from location or course tracking mode to heading tracking mode. Fixes #3710. --- platform/ios/src/MGLMapView.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 954fc8a93..2851efecd 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3064,14 +3064,15 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) mode = MGLUserTrackingModeNone; } + MGLUserTrackingMode oldMode = _userTrackingMode; _userTrackingMode = mode; - - self.userTrackingState = animated ? MGLUserTrackingStatePossible : MGLUserTrackingStateChanged; switch (_userTrackingMode) { case MGLUserTrackingModeNone: { + self.userTrackingState = MGLUserTrackingStatePossible; + [self.locationManager stopUpdatingHeading]; // Immediately update the annotation view; other cases update inside @@ -3083,6 +3084,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) case MGLUserTrackingModeFollow: case MGLUserTrackingModeFollowWithCourse: { + self.userTrackingState = animated ? MGLUserTrackingStatePossible : MGLUserTrackingStateChanged; self.showsUserLocation = YES; [self.locationManager stopUpdatingHeading]; @@ -3096,6 +3098,11 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) } case MGLUserTrackingModeFollowWithHeading: { + if (oldMode == MGLUserTrackingModeNone) + { + self.userTrackingState = animated ? MGLUserTrackingStatePossible : MGLUserTrackingStateChanged; + } + self.showsUserLocation = YES; if (self.zoomLevel < self.currentMinimumZoom)