I'm able to get map click events and want to turn off the click event handler once the event is received and handled.
I want to remove the event handler so that subsequent clicks on the map no longer cause the event handler to be invoked.
view.on("click", function(event) {
var point = "point: (" + event.mapPoint.latitude + ", " + event.mapPoint.longitude + ")";
console.log("click event: ", point);
findStores(event.mapPoint.latitude, event.mapPoint.longitude);
// now I want to disable the click event until it is re-enabled
});
Since you tagged your question with arcgis
I assume the view
in your code example is an instance of esri/views/View
.
Then, simply following the documentation for view.on()
, you just need to store and call the remove handler:
var handler = view.on("click", function(event) {
var point = "point: (" + event.mapPoint.latitude + ", " + event.mapPoint.longitude + ")";
console.log("click event: ", point);
findStores(event.mapPoint.latitude, event.mapPoint.longitude);
handler.remove();
});