Search code examples
javascriptesriarcgis-js-api

Disabling zoom in double click in ESRI map


I am using ESRI map version 4.1 for generating map in my angular application and its working fine. What I want now is to disable zoom on double click on the map. I have done lot of googling and most of them suggestion stopPropagation() method, but the event itself is not having this function and its throwing error.

what I have tried is

view.on('double-click', function(event){
    event.stopPropagation()
});

It is giving me the error

event.stopPropagation is not a function

I am using ESRI javascript library version 4.1.

Anybody has any idea how can I stop zooming on double click?


Solution

  • Esri 4.1 did not provide this feature in the library. You must either upgrade or intervene. In this way, you can intervene and control the "double-click" event with your own method.

    https://codepen.io/mcantonbul/pen/YzKVRQJ

    require(["esri/Map", "esri/views/MapView"], function(Map, MapView) {
      var map = new Map({
        basemap: "streets"
      });
    
      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 4,
        center: [15, 65] // longitude, latitude
      });
      var myCustomDoubleClick = function(event) {
        console.log(event);
      };
      view.gestureManager.handlers.last["double-click"] = myCustomDoubleClick;
    });