You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: correct center calculation in flyTo when minZoom is set (#7743)
* fix: correct center calculation in flyTo when minZoom is set
When minZoom causes zoom to be clamped by applyConstrain(), the theoretical
scale from Van Wijk formula becomes inconsistent with tr.worldSize. This
causes center to jump during the animation.
Fix by computing actualScale from the clamped tr.zoom after setZoom, ensuring
the scale and worldSize are derived from the same zoom value.
* docs(changelog): add flyTo minZoom fix entry
* fix: use stable worldSize in camera easing
Save tr.worldSize to startWorldSize before calling setZoom and use it for
project/unproject calculations. This prevents inconsistencies caused by
tr.setZoom (and minZoom clamping) modifying tr.worldSize during the easing
path computation, ensuring the center interpolation is based on a consistent
world scale.
* test: add flyTo center movement test with minZoom limit
* fix: respect map.setMinZoom in flyTo rho calculation
Previously, scaleOfMinZoom was only computed when minZoom was passed
directly in flyTo options. If the user had called map.setMinZoom(X),
tr.minZoom would be set but options.minZoom would be undefined, causing
scaleOfMinZoom to remain unset and the rho recalculation in camera.ts to
be skipped entirely. This meant that the flight path is not optimal when the user has set a minZoom level on the map.
* fix: make flyTo minZoom a ceiling constraint, not a target
The minZoom option in flyTo should act as a ceiling that prevents
the flight arc from zooming out beyond the specified level, rather
than forcing the arc to peak at that zoom level.
* refactor: simplify minZoom constraint logic
Remove unnecessary conditional branches and constants by always computing the effective minimum zoom.
* test: refactor camera flyTo minZoom tests to sample all frames
Replace nested setTimeout callbacks with a deterministic frame-by-frame
sampling loop. This improves test reliability by capturing zoom values
across the entire animation arc instead of relying on specific timing
assumptions. Update assertions to use collected zoom values for more
robust validation.
* test: refactor flyTo frame timing tests with async/await
Refactor nested setTimeout callbacks to async/await pattern for improved code clarity.
* refactor: remove redundant scaleOfMinZoom type guard
* test: extract animation frame simulation helper
---------
Co-authored-by: Harel M <harel.mazor@gmail.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
-_...Add new stuff here..._
4
4
5
5
### 🐞 Bug fixes
6
+
- Fix camera jump in flyTo when minZoom is set ([#7743](https://github.com/maplibre/maplibre-gl-js/pull/7743)) (by [@YuChunTsao](https://github.com/YuChunTsao))
0 commit comments