Skip to content
9 changes: 9 additions & 0 deletions platform/ios/src/MLNMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,15 @@ vertically on the map.
*/
@property (nonatomic, getter=isRotateEnabled) BOOL rotateEnabled;

/**
The threshold, measured in degrees, that determines when the map's bearing will snap to north.
For example, with a toleranceForSnappingToNorth of 7, if the user rotates the map within 7 degrees
of north, the map will automatically snap to exact north.

The default value of this property is 7.
*/
@property (nonatomic) CGFloat toleranceForSnappingToNorth;

/**
A Boolean value that determines whether the user may change the pitch (tilt) of
the map.
Expand Down
8 changes: 3 additions & 5 deletions platform/ios/src/MLNMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ typedef NS_ENUM(NSUInteger, MLNUserTrackingState) {
/// Initial zoom level when entering user tracking mode from a low zoom level.
const double MLNDefaultZoomLevelForUserTracking = 14.0;

/// Tolerance for snapping to true north, measured in degrees in either direction.
const CLLocationDirection MLNToleranceForSnappingToNorth = 7;

/// Distance threshold to stop the camera while animating.
const CLLocationDistance MLNDistanceThresholdForCameraPause = 500;

Expand Down Expand Up @@ -883,6 +880,7 @@ - (void)commonInitWithOptions:(MLNMapOptions*)mlnMapoptions
[self addGestureRecognizer:_rotate];
_rotateEnabled = YES;
_rotationThresholdWhileZooming = 3;
_toleranceForSnappingToNorth = 7;

_doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTapGesture:)];
_doubleTap.numberOfTapsRequired = 2;
Expand Down Expand Up @@ -6839,8 +6837,8 @@ - (void)unrotateIfNeededForGesture
[self unrotateIfNeededAnimated:YES];

// Snap to north.
if ((self.direction < MLNToleranceForSnappingToNorth
|| self.direction > 360 - MLNToleranceForSnappingToNorth)
if ((self.direction < self.toleranceForSnappingToNorth
|| self.direction > 360 - self.toleranceForSnappingToNorth)
&& self.userTrackingMode != MLNUserTrackingModeFollowWithHeading
&& self.userTrackingMode != MLNUserTrackingModeFollowWithCourse)
{
Expand Down