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

Commit

Permalink
[ios] snap to north if interaction ends within ±7°
Browse files Browse the repository at this point in the history
First proposed in #938, implemented in #1059, reverted in #1064.
  • Loading branch information
friedbunny committed Dec 24, 2015
1 parent d2b2336 commit e4d8494
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e4d8494

Please sign in to comment.