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?


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) {




    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.

1 Answer 1


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


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

  • Well, I can't explain it. I refreshed the page over an over and it didn't make a difference. When I stopped debugging and restarted debugging. Everything works.
    – Brian
    Apr 8, 2013 at 23:08
  • 1
    I've found oftentimes that when making changes like this it's a good idea to clear the browser cache when refreshing. It's yet another reason I love Firebug, which lets you disable the browser cache for whatever site you're testing. Apr 9, 2013 at 13:36
  • Do you know if that is possible with Chrome DevTools?
    – Brian
    Apr 9, 2013 at 15:48
  • 1
    Yup, if you click the gear in the bottom right of the DevTools, you should see a Disable cache checkbox close to the top. Apr 9, 2013 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.