Select to view content in your preferred language

Identify Tool and Measurement Tool Events

2590
2
06-03-2011 06:50 AM
Donald_EricPimpler
Emerging Contributor
Hi,

I'm building an application that has the ability to perform measurement through the Measurement Tool along with identify functionality in 2.3 of the API.  Both tools work with the map.click event.  I understand the mechanics of how to stop an event so that for instance when the user clicks the map to perform an identify that it doesn't also perform a measurement.  However, with the measure tools I don't see any exposed events that would allow me to stop an event.  For example, when the user clicks the Measure Distance tool and then clicks the map to define the first point it also attempt to perform an identify and vice versa.

Anyone know how to handle this?

Thanks,

Eric Pimpler
GeoSpatial Training Services, Inc.
http://www.geospatialtraining.com
http://geochalkboard.wordpress.com
0 Kudos
2 Replies
HemingZhu
Frequent Contributor
Hi,

I'm building an application that has the ability to perform measurement through the Measurement Tool along with identify functionality in 2.3 of the API.  Both tools work with the map.click event.  I understand the mechanics of how to stop an event so that for instance when the user clicks the map to perform an identify that it doesn't also perform a measurement.  However, with the measure tools I don't see any exposed events that would allow me to stop an event.  For example, when the user clicks the Measure Distance tool and then clicks the map to define the first point it also attempt to perform an identify and vice versa.

Anyone know how to handle this?

Thanks,

Eric Pimpler
GeoSpatial Training Services, Inc.
http://www.geospatialtraining.com
http://geochalkboard.wordpress.com


Thanks for the clue on Jian's post on http://forums.arcgis.com/threads/31664-How-to-modify-measurement-widget, it is feasible by code like this;

var clickMode =true; //globle variable. default as enable click event
....
dojo.connect(map, "onClick", doIdentify);
....
var measurement = new esri.dijit.Measurement({
                map: map
}, dojo.byId('measurementDiv'));
measurement.startup();
var distanceBtn = dojo.query('[widgetid=\"distance\"]')[0];
dojo.connect(distanceBtn, "onclick", function() { //note: onclick not onClick
    clickMode =false; //deactivate the click identify event
});
...

function doIdentify(evt)
{
    if (!clickMode) return;
    else
    {
        .... identify action go here;
       clickMode =true; //reset back
    }
}
0 Kudos
JimWharton
Occasional Contributor
Thanks for the clue on Jian's post on http://forums.arcgis.com/threads/31664-How-to-modify-measurement-widget, it is feasible by code like this;

var clickMode =true; //globle variable. default as enable click event
....
dojo.connect(map, "onClick", doIdentify);
....
var measurement = new esri.dijit.Measurement({
                map: map
}, dojo.byId('measurementDiv'));
measurement.startup();
var distanceBtn = dojo.query('[widgetid=\"distance\"]')[0];
dojo.connect(distanceBtn, "onclick", function() { //note: onclick not onClick
    clickMode =false; //deactivate the click identify event
});
...

function doIdentify(evt)
{
    if (!clickMode) return;
    else
    {
        .... identify action go here;
       clickMode =true; //reset back
    }
}


There are a few issues with this. 1. You are attempting to change the clickMode Global back to TRUE in part of a loop that will never get executed. (if clickMode is false). 2. It looks like clicking the distanceBtn you query for fires multiple click events.

Perhaps a better way to set the bool is checking the 'aria-pressed' property on that toggle button.

In my case, it had the widgetid of 'dijit_form_ToggleButton_1'.

I hope this helps someone.
0 Kudos