I have a custom onClick
handler for my map that is meant to add a point wherever the map is clicked. I'm finding that this function is triggered even when I click the map to pan. Is it possible to somehow ignore the onClick
event if the map is panning?
Update:
Here is the code for my onClick
handler.
this.mapClickHandle = dojo.connect(this.map, "onClick", lang.hitch(this, function(evt) {
this.layers.forEach(function(layer) {
layer.layerObject.clearSelection();
});
console.log(evt.screenPoint)
var toleranceInPixels = 10;
var pnt = evt.mapPoint;
var pixelWidth = this.map.extent.getWidth() / this.map.width;
var toleranceInMapCoords = toleranceInPixels * pixelWidth;
var ext = new esri.geometry.Extent(pnt.x - toleranceInMapCoords, pnt.y - toleranceInMapCoords, pnt.x + toleranceInMapCoords, pnt.y + toleranceInMapCoords, this.map.spatialReference);
var q = new esri.tasks.Query();
q.geometry = ext;
var deferreds = this.layers.map(function(layer) {
return layer.layerObject.selectFeatures(q);
});
all(deferreds).then(lang.hitch(this, function(results) {
if (results.some(
function(result) {
return result.length > 0;
})) {
dijit.byId(this.mapPage).performTransition(this.attributePage, 1, "fade", null);
} else {
if (this._editing) {
this._newGeom = evt.mapPoint;
dijit.byId(this.mapPage).performTransition(this.templatePage, 1, "fade", null);
}
}
}));
}));
This is for a mobile web application using the JS API v3.4. The behavior I am seeing is still in my desktop web browser though. Basically, what the code above does is transition to the attribute view if an existing feature is clicked on (or nearby) or it transitions to the editor template page if the map is clicked and not existing features are nearby.