phasor555
phasor555

Reputation: 265

Is there a way to disable double touch zoom?

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.

Upvotes: 6

Views: 4286

Answers (2)

Clark
Clark

Reputation: 488

If you want to full disable Touch zoom and rotation, you can do it via setting touchZoomRotate to false (API docs)

What I was attempting to do, wasn't to disable pinch zoom or double touch zoom, but to only disable the double tap to switch dragging from pan to zoom. (This is slightly counter-intuitive in my opinion).

There's an undocumented API feature to just disable the touch drag zoom by setting:

mapRef.current.touchZoomRotate['_tapDragZoom']['_enabled'] = false;

Credit to this related post

Upvotes: 0

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.

Upvotes: 1

Related Questions