[GIS] How to prevent Mapbox GL JS FlyTo animation from being interrupted

mapboxmapbox-gl

If a user clicks, swipe scrolls on mobile, or interacts with the map in any way, the flyTo animation is canceled. How can I stop that?

Or at the very least, jump to the destination?

Best Answer

On my mobile device, flyTo fails the instant my keyboard hides after geocoder input. It appears the onscreen keyboard display and hiding interferes with the flyTo animation. This workaround corrected my issue:

var map = new mapboxgl.Map({
  container: 'map',
  animate: false
});

var geocoder = new MapboxGeocoder({
  accessToken: mapboxgl.accessToken,
  flyTo: false
});

geocoder.on('result', function(ev) {
    map.jumpTo({
        center: ev.result.center
    });
});