0

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?

2
  • codepen.io/mcantonbul/pen/YzKVRQJ It's working. Can u create example app? or I think you could try changing the name of the "event" variable. Commented Aug 28, 2019 at 6:53
  • I am Using version 4.1. I have tried this link with 4.1 instead of 4.12, but its now zooming on double click:(
    – Sabith
    Commented Aug 28, 2019 at 7:48

2 Answers 2

1

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;
});
1
  • stopPropagation disables everything for that event. Is there a way to only disable zoom?
    – tcrite
    Commented Jul 27, 2020 at 12:41
0

try something like ,

$( "#target" ).dblclick(function(event) {
 event.stopPropagation()
});
5
  • Which element you meant by id 'target'? Double click is on the view itself, and its svg created by esri library
    – Sabith
    Commented Aug 28, 2019 at 6:00
  • in your case "target" should be "view"
    – Akash
    Commented Aug 28, 2019 at 7:37
  • As you probably know, these are the selectors. I hope, when you are trying to bind an "double-click" event to the "view" element than that element id is "view".
    – Akash
    Commented Aug 28, 2019 at 7:39
  • 1
    Thank you Akash for your response, but I guess you misunderstood the concept. This view is an svg element created by ESRI library as a view. Unlike normal svg, ESRI will create its own event handlers on 'view'. 'view' is not the id, it is the reference on which many functions are bound by library. FYI, here I am talking about ESRI Map view, not about DOM element. See this link : codepen.io/mcantonbul/pen/YzKVRQJ , you will get an idea
    – Sabith
    Commented Aug 28, 2019 at 7:44
  • I see your point after looking at that codepen. yes, I misunderstood it and was thinking in terms of DOM only.
    – Akash
    Commented Aug 28, 2019 at 8:09

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