0

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

1

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]});
0

Another option to solve this will be using map.easeTo(...) to support both location change and rotation change without waiting for moveend using a single call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.