If you're initiating identify with map onClick you can use dojo/on once.on.once(map, 'click', function(evt) {
//do stuff
});
To manage the event outside itself.var clickTheMap = on(map, 'click', function(evt) {
//remove event when fired (equivalent to on.once)
clickTheMap.remove();
clickTheMap = null;
//do stuff
});
on(myCancelButton, 'click', function() {
if(clickTheMap) {
clickTheMap.remove();
}
});
If you have a lot of map events consider a helper class to manage said events. Here's the relevant parts of mine. Keep in mind I just copy/pasted this as an example to illustrate to concept. Will probably take some adaptation to implement in your app./* map event handling */
// primarily used for map 'click' events
// however any on-style event can be added
// does not support connect events
eventAdd: function (event) {
this.eventOns.push(event);
},
eventBegin: function () {
this.infoWindow.hide();
this.infoWindow.clearFeatures();
this.setMapCursor('default');
this.eventMouseEventsDisable();
arrayUtils.forEach(this.eventOns, function (o) {
o.remove();
});
this.eventOns = [];
if (this.drawToolbar._geometryType != null) {
this.drawToolbar.deactivate();
}
var s = esriBundle.toolbars.draw;
s.addPoint = 'Click to add a point';
s.freehand = 'Press down to start and let go to finish';
s.start = 'Click to start drawing';
s.resume = 'Click to continue drawing';
s.complete = 'Double-click to finish';
},
eventEnd: function () {
this.setMapCursor('default');
this.eventMouseEventsEnable();
this.toaster.hide();
},
eventReset: function () {
this.eventBegin();
this.eventEnd();
},
eventMouseEventsEnable: function () {
arrayUtils.forEach(this.graphicsLayerIds, function (layer) {
this.getLayer(layer).enableMouseEvents();
}, this);
},
eventMouseEventsDisable: function () {
arrayUtils.forEach(this.graphicsLayerIds, function (layer) {
this.getLayer(layer).disableMouseEvents();
}, this);
},
Used like this.this.map.eventBegin();
this.map.setMapCursor('crosshair');
this.map.drawToolbar.activate('point');
var o = on.once(this.map.drawToolbar, 'draw-end', lang.hitch(this, function (result) {
this.map.eventEnd();
//do stuff
}));
this.map.eventAdd(o);