[GIS] ESRI JS API – don’t trigger onClick event when panning Map

arcgis-javascript-apicartographyeventsjavascript

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.

Best Answer

This sample would suggest that the API already separates a single click from drag events quite well (as well as double clicks).

http://developers.arcgis.com/en/javascript/samples/map_infowindow/

Would you mind posting some code or at least explaining what you're doing with your custom onclick handler?