5

On the Mapbox API reference page, there are 7 listed objects that allow you to enable and disable user interactions. There is BoxZoomHandler, ScrollZoomHandler, DragPanHandler, DragRotateHandler, KeyboardHandler, DoubleClickZoomHandler, and TouchZoomRotateHandler.

https://docs.mapbox.com/mapbox-gl-js/api/#user%20interaction%20handlers

For example, to disable double click zoom with the mouse, you do map.DoubleClickZoomHandler.disable().

I want to disable the double touch zoom, but I see no reference for it. Does anyone know how to accomplish this?

Edit: I'm using Windows 10 and Google Chrome browser.

2
  • Welcome to StackOverflow! It might be worth noting what platforms (Web browsers and OSes) you're observing double-touch zoom on. Commented Mar 12, 2019 at 21:35
  • I'm not familiar with the mapbox api, but you might want to look at affixing ontouchstart to the element you want to disable the behavior on and then preventing the default event. For a button for example, disabling the default ontouchstart behavior would prevent double clicking the button to zoom, and from there you could call the original click functionality. Small demo shows it here, will need to view on mobile or enable mobile view in chrome codepen.io/jensbodal/pen/moqpwg
    – Jens Bodal
    Commented Mar 12, 2019 at 22:45

1 Answer 1

1

The DoubleClickZoomHandler manage also the double tap see: https://docs.mapbox.com/mapbox-gl-js/api/#doubleclickzoomhandler

The DoubleClickZoomHandler allows the user to zoom the map at a point by double clicking or double tapping.

So, you can use it to disable the double touch.

1
  • Doesn't work. I cannot zoom with double click and tap anymore, but double tap and drag (with one finger) still zooms! It should scroll the page instead.
    – ygoe
    Commented Apr 16, 2021 at 18:45

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