Mapbox-gl-js: flyTo callback

Created on 3 Dec 2015  路  6Comments  路  Source: mapbox/mapbox-gl-js

Would be nice to have a callback function when a flyTo animation is complete.

feature

Most helpful comment

I think it's better to rely on map.once('moveend', fn) here. To add a reliable callback to flyTo directly, we need to add some ugly hacks, otherwise e.g. it won't be fired when stopped externally before it finishes.

All 6 comments

Can you listen for the moveend event?

Yes but it would be nice/clearer to do it within flyTo

I think it's better to rely on map.once('moveend', fn) here. To add a reliable callback to flyTo directly, we need to add some ugly hacks, otherwise e.g. it won't be fired when stopped externally before it finishes.

:+1: this is a good solution. Closing.

I use this solution:

map.on('moveend', ({ originalEvent }) => {
  if (originalEvent) {
    map.fire('usermoveend');
  } else {
    map.fire('flyend');
  }
});

You can do the same for movestart.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgentry picture bgentry  路  3Comments

BernhardRode picture BernhardRode  路  3Comments

PBrockmann picture PBrockmann  路  3Comments

shotor picture shotor  路  3Comments

aderaaij picture aderaaij  路  3Comments