Vector layers drift away on flyTo when zoomAnimation = false
See original GitHub issue- I’ve looked at the documentation to make sure the behavior is documented and expected
- I’m sure this is a Leaflet code issue, not an issue with my own code nor with the framework I’m using (Cordova, Ionic, Angular, React…)
- I’ve searched through the issues to make sure it’s not yet reported
Steps to reproduce Steps to reproduce the behavior:
- create a map with option
zoomAnimation: false
- create a vector layer (e.g a polygon) and add to map
- use map.flyTo() to pan to any point
Expected behavior Vector layers follow the movement of the map.
Current behavior Vector layers drift away while panning. When the target is reached they snap to their proper location. This is even more perceptible when the zoom levels between the current position and the target differ.
Environment
- Leaflet version: 1.7.1
- Browser (with version): Firefox 85.0.1
- OS/Platform (with version): Ubuntu 20.10
Additional context
My current workaround is to set mapInstance._zoomAnimated = true
before I add a layer and map._zoomAnimated = false
right after. This way the animation handler will be registered in src/layer/vector/Renderer.js while keeping the zoom animation disabled.
Minimal example reproducing the issue
https://plnkr.co/edit/qHqGIded24Z4MYtO
- this example is as simple as possible
- this example does not rely on any third party code
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Leaflet Vector Layers Not Rendering During FlyTo Animation
The vectors should redraw properly. The quote by @nathansnider is referring to the fact that vectors are not reprojected, but they animate with ......
Read more >leaflet/CHANGELOG.md - UNPKG
62, * Fix `L.TileLayer`regression, which caused incorrect tile URLs ... 530, * Fixed vector layer positioning during a zoom animation in low zoom...
Read more >leaflet | Yarn - Package Manager
Added Layer class which all layers added to a map should inherit from. · Added remove method to layers and controls ( marker....
Read more >OpenLayers 3 Vector wrong position with zoom - Stack Overflow
I try draw a vector image on map using OpenLayers 3. The image behaves strange when using zoom on the map. To demonstrate...
Read more >ol/layer/Vector~VectorLayer - OpenLayers
This means that no vectors will be shown clipped, but the setting will have a performance impact for large amounts of vector data....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can offer to investigate further as soon as I have the time. Could be next week.
I have got a more general applicable workaround that might help:
It specifically runs the excluded code path in Renderer.js - onAdd method where the
leaflet-zoom-animated
class is set to the renderer-container. This fixes the difting layers while keeping other zoomAnimation effects disabled.