From e4d84948524844667c742d7d5e0b2c0c4295cde7 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 23 Dec 2015 14:40:24 -0500 Subject: [PATCH] =?UTF-8?q?[ios]=20snap=20to=20north=20if=20interaction=20?= =?UTF-8?q?ends=20within=20=C2=B17=C2=B0=20First=20proposed=20in=20#938,?= =?UTF-8?q?=20implemented=20in=20#1059,=20reverted=20in=20#1064.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60769096deb..935fa1c211c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Known issues: - MGLMapCamera’s `altitude` values now match those of MKMapCamera. ([#3362](https://github.com/mapbox/mapbox-gl-native/pull/3362)) - The user dot’s callout view is now centered above the user dot. It was previously offset slightly to the left. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261)) - Fixed an issue with small map views not properly fitting annotations within bounds. (#[3407](https://github.com/mapbox/mapbox-gl-native/pull/3407)) +- The map will now snap to north. ([#3403](https://github.com/mapbox/mapbox-gl-native/pull/3403)) ## iOS 3.0.1 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index af3adae6b18..5eee1d52ffb 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3027,6 +3027,8 @@ - (BOOL)isRotationAllowed // - (void)unrotateIfNeededAnimated:(BOOL)animated { + double snapTolerance = 7; + // don't worry about it in the midst of pinch or rotate gestures // if (self.pinch.state == UIGestureRecognizerStateChanged || self.rotate.state == UIGestureRecognizerStateChanged) return; @@ -3057,6 +3059,10 @@ - (void)unrotateIfNeededAnimated:(BOOL)animated [self resetNorthAnimated:NO]; } } + else if (self.direction < snapTolerance || self.direction > 360 - snapTolerance) + { + [self resetNorthAnimated:animated]; + } } - (void)notifyMapChange:(mbgl::MapChange)change