3

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?

1
  • On mobile devices my flyTo is being interrupted on a mobile device after typing an address in the geocoder box. It doesn't happen on desktop so I'm assuming it's because the keyboard is changing the display size.?
    – wilsotc
    Jan 23, 2017 at 14:34

2 Answers 2

2

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

What worked for me was to disable all map events via Mapbox API and interaction with the canvas element with some css:

.mapboxgl-canvas {
  pointer-events: none;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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