Skip to content

fix: convert pinch scale to zoom through the CRS instead of log2 - #2278

Open
WudgeJalk wants to merge 1 commit into
fleaflet:masterfrom
WudgeJalk:fix/pinch-zoom-through-crs
Open

WudgeJalk wants to merge 1 commit into
fleaflet:masterfrom
WudgeJalk:fix/pinch-zoom-through-crs

Conversation

@WudgeJalk

Copy link
Copy Markdown

Part of #2269 (step 2 of the split).

_getZoomForScale converts the pinch scale with zoom + log2(scale), which only holds when each level doubles the scale. On a Proj4Crs with other resolutions (Swiss LV95: 2.5 → 2 → 1.5 → 1 m/px) spreading the fingers ×2 scales the map by ×1.25 at some levels and ×2.5 at others.

Now crs.zoom(crs.scale(startZoom) * scale) — the formula of MapCamera.getScaleZoom, applied to the gesture's start zoom. Identical in EPSG:3857 (crs.scale is 256 · 2^z), so no behaviour change there. Covers pinch, the gesture-race threshold and double-tap zoom, which all go through this function. Scroll wheel and double-tap-drag are zoom deltas by API, unchanged.

Test: test/gestures/pinch_zoom_crs_test.dart — fingers ×2 on the LV95 resolutions: master scales the map by 1.25, fixed by 2; EPSG:3857 adds one level before and after. Full suite passes (142).

🤖 Generated with Claude Code

`_getZoomForScale` used `zoom + log2(scale)`, which only holds when each
level doubles the scale. It now uses `crs.zoom(crs.scale(zoom) * scale)`,
the formula of `MapCamera.getScaleZoom`, identical in EPSG:3857, so
pinching x2 doubles the map scale in any CRS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant