maplibre-gl-js
maplibre-gl-js copied to clipboard
Zooming by mouse/touchpad is disabled/really lagging while animating the center of the map from the JS API
maplibre-gl-js version: 2.1.9
browser: Chrome
Steps to Trigger Behavior
- Set up an animation that uses
requestAnimationFrame
to set the center of the map with eithersetCenter
,easeTo
orpanTo
- Try to change the zoom of the map
Link to Demonstration
https://jsfiddle.net/jr23t5wy/3/
based on https://maplibre.org/maplibre-gl-js-docs/example/animate-point-along-line/
Expected Behavior
Zoom is not affected by any means by the calls to setCenter
Actual Behavior
It seams that those two are not independent, therefore frequent calls to setCenter
effectively disables manual zoom.
Remark: My goal is to create a (sort of) navigation app, so the point is to have a marker indicating a car (ego vehicle) with a symbol layer and geojson source and keeping the car in the middle of the map. I update the car location (== the Point feature) and the center of the map at 60 FPS.
I think I had a similar issue I encountered recently with animating the map to indicate the north when using the device compass. Can you check if this happens with mapbox version 1.0? I think this issue was introduced between 1.0 and 1.2.
Here you go: https://jsfiddle.net/jr23t5wy/4/
It is better there, zoom is responsive, but while I zoom, the center is not set as I would expect. It seems like setCenter
is ignored during zoom.
This makes sense as when you zoom you "freeze" the center around the zoom. Helping find the commit that introduced this issue would help a lot as we can better understand maybe where the code to fix this...
I am not too familiar with the code base, but I can try to find the first release where this went wrong.
Sorry for the delay, I was not able to find the time to check upon this until now. The last working version is 1.9.1 (jsFiddle), and the first version that has this issue is 1.10.0 (jsFiddle)
I'm guessing there's not many file changes between those releases, and even less are about touch and gestures I guess. Finding and understanding the code that changed should be possible for you, I hope.