diff options
author | Jason Wray <jason@mapbox.com> | 2015-12-23 14:40:24 -0500 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2015-12-24 13:45:51 -0500 |
commit | e4d84948524844667c742d7d5e0b2c0c4295cde7 (patch) | |
tree | 57149e83f682165a3ea4a7f80e8aff96c799d20b | |
parent | d2b2336a9efc00978950cd3ee9d4d0af6ad7f1bf (diff) | |
download | qtlocation-mapboxgl-e4d84948524844667c742d7d5e0b2c0c4295cde7.tar.gz |
[ios] snap to north if interaction ends within ±7°
First proposed in #938, implemented in #1059, reverted in #1064.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 60769096de..935fa1c211 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 af3adae6b1..5eee1d52ff 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3027,6 +3027,8 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) // - (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 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) [self resetNorthAnimated:NO]; } } + else if (self.direction < snapTolerance || self.direction > 360 - snapTolerance) + { + [self resetNorthAnimated:animated]; + } } - (void)notifyMapChange:(mbgl::MapChange)change |