Leaflet / Leaflet

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦
https://leafletjs.com
BSD 2-Clause "Simplified" License
41.14k stars 5.82k forks source link

Layers with animated coordinates shift incorrectly when zooming #9373

Open FeldrinH opened 3 months ago

FeldrinH commented 3 months ago

Checklist

Steps to reproduce

Create a CircleMarker, Polyline or other similar layer and then change its coordinates. Try zooming in and out while the coordinates change.

Expected behavior

The layer stays in its place.

Current behavior

The layer briefly jumps to an incorrect location while the zoom animation is ongoing. Layers where the coordinates are not actively changed behave correctly and stay in place.

Note: The issue seems to happen with both the canvas and SVG renderer.

Minimal example reproducing the issue

https://plnkr.co/edit/Ezv0b0skouMOfZXZ?preview

https://github.com/Leaflet/Leaflet/assets/5256211/0ed10dd2-d9e3-41d1-b710-cbb02a93512e

Environment

FeldrinH commented 3 months ago

It appears that this is a partial regression. In older Leaflet versions the zooming of moving vector layers was working correctly with scrollwheel zoom, but had the same issue that it has now on mobile with pinch zoom (going back to Leaflet 1.0.0 I could not find a version where pinch zoom worked correctly with moving vector layers).

With some local testing I determined that the first commit where scrollwheel zoom has issues with vector layers is https://github.com/Leaflet/Leaflet/commit/48a38c797b19cefb28002f7d09199d947260106a, which was introduced in PR https://github.com/Leaflet/Leaflet/pull/7967.

@Falke-Design since you are the original author of that PR, do you have any insight on this issue?

N1ve5h commented 3 months ago

@FeldrinH I have a workaround for the issue. What I did what stop the interval when zoom animation starts and start the interval when the zoom animation ends. Example