diff --git a/platform/ios/src/MLNMapView.h b/platform/ios/src/MLNMapView.h index 727ea0610..d4e7fc328 100644 --- a/platform/ios/src/MLNMapView.h +++ b/platform/ios/src/MLNMapView.h @@ -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. diff --git a/platform/ios/src/MLNMapView.mm b/platform/ios/src/MLNMapView.mm index 8a6b9542e..56f5a385c 100644 --- a/platform/ios/src/MLNMapView.mm +++ b/platform/ios/src/MLNMapView.mm @@ -290,9 +290,6 @@ const double MLNMinimumZoomLevelForUserTracking = 10.5; /// 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; @@ -883,6 +880,7 @@ public: [self addGestureRecognizer:_rotate]; _rotateEnabled = YES; _rotationThresholdWhileZooming = 3; + _toleranceForSnappingToNorth = 7; _doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTapGesture:)]; _doubleTap.numberOfTapsRequired = 2; @@ -6839,8 +6837,8 @@ static void *windowScreenContext = &windowScreenContext; [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) {