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?
2 Answers
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]});
-
1Looks like it was a bug and it got fixed github.com/mapbox/mapbox-gl-js/issues/2855 :)– LCLAug 10, 2016 at 14:56
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.