Skip to content

Commit 8c2bb04

Browse files
committed
fix jumps when using the mouse to rotate past 90 degrees pitch
1 parent 365fe94 commit 8c2bb04

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/geo/projection/mercator_camera_helper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export class MercatorCameraHelper implements ICameraHelper {
3535
}
3636

3737
handleMapControlsPan(deltas: MapControlsDeltas, tr: ITransform, preZoomAroundLoc: LngLat): void {
38+
// If we are rotating about the center point, there is no need to update the transform center. Doing so causes
39+
// a small amount of drift of the center point, especially when pitch is close to 90 degrees.
40+
// In this case, return early.
41+
if (deltas.around.distSqr(tr.centerPoint) < 1.0e-2) {
42+
return;
43+
}
3844
tr.setLocationAtPoint(preZoomAroundLoc, deltas.around);
3945
}
4046

0 commit comments

Comments
 (0)