Add configurable threshold for rotate gesture snapping to north (#3914)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jesse Crocker
2025-10-31 08:00:11 -06:00
committed by GitHub
parent 76da093e5e
commit 4c31a52a3c
2 changed files with 12 additions and 5 deletions

View File

@@ -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.

View File

@@ -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)
{