dclipca
dclipca

Reputation: 1937

Edit camera center directly and instantly in Mapbox GL JS

I want to edit the camera center directly in Mapbox GL JS. I know about the existence of the map.easeTo and map.flyTo methods but I do not want to use them because I have to do multiple requests to them (around 60 per second), which in turn results in decreased performance because transitions are stacking upon each other (only an assumption from my side).

Essentially, instead of doing map.flyTo or map.easeTo, I want to do change the camera center directly and instantly. Alternatively, I would like to know if it is possible to remove all the previous transitions before calling map.flyTo or map.easeTo.

Upvotes: 0

Views: 973

Answers (1)

AndrewHarvey
AndrewHarvey

Reputation: 3055

To update the camera without an animation use Map#jumpTo.

If you're trying to do your own smooth camera animation you might want to also use requestAnimationFrame like in https://docs.mapbox.com/mapbox-gl-js/example/animate-camera-around-point/

Upvotes: 3

Related Questions