[GIS] How to prevent map click event esri map js API

arcgis-javascript-apievents

I have a map and I'm listening a click event like this,

 currentMap.on("click",this.identifyMapFeature.bind(this));

At some extent I want to disable the click event from map, I've tried these 3 methods from esri js API docs,

    this.currentMap.disableMapNavigation();
    this.currentMap.disablePan();
    this.currentMap.disableScrollWheelZoom();

but still click event is firing , is there any method like disableMapClick() to disable map click ?

Best Answer

You can use dojo/on's pausable method to pause and resume any type of event. You will have to add the "dojo/on" module in your require statement.

require(["dojo/on"], function(on){
  var buttonHandler = on.pausable(button, "click", clickHandler);

  on(disablingButton, "click", function(){
    buttonHandler.pause();
  });

  on(enablingButton, "click", function(){
    buttonHandler.resume();
  });
});