[GIS] Rotate Mapbox GL JS map after flyTo transition

mapbox-gl-js

I can't seem to have much luck chaining a rotateTo transition after a flyTo transition, here are 2 examples the first one chains another flyTo transition after the 'moveend' event is fired, this works but if I try to rotate instead, no luck. Am I trying to do something silly?

Fly after transition

Rotate after transition

Best Answer

I tried your rotate after transition example, and saw the same error you encountered (only flyTo operation works, rotateTo did not).

But when I swapped the operations (map.rotateTo() first, then map.flyTo()), then I was able to get both operations to work.

I see that #2855 has been filed in mapbox-gl-js.

It may not fit into your workflow, but it appears that you can achieve both operations by swapping. Then awaiting the response from Mapbox on Github issues.


This works

map.once('moveend', function(){
    console.log('moveend logging');
  map.flyTo({  center: [-74.50, 40]});
});

map.rotateTo(45.0, {duration:3000});  

This did not

map.once('moveend', function(){
    console.log('moveend logging');
    map.rotateTo(45.0, {duration:3000});
});

map.flyTo({  center: [-74.50, 40]});