Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to set up an Identify button that will only allow the identify functionality to be performed when the button is pressed. I have gotten to the point that the identify only works when the button has been pushed the first time but I can't seem to turn the button off. I have pasted a few bits of code below or you can follow the link to see the entire thing.

Funtion to activate Identify

function activateIdentify(){
    if (dijit.byId("tool_identify").checked) {
        dojo.connect(map, "onClick", executeIdentifyTask);

Button to Activate function

<div dojoType="dijit.form.ToggleButton" id="tool_identify" iconClass="dijitCheckBoxIcon" onClick="activateIdentify();" >Identify</div>

Function to toggle buttons

function toggleButtonIcon(tool) {

    //only the tools in the toolbar are dijit togglebuttons so can iterate thru them
    dijit.registry.byClass("dijit.form.ToggleButton").forEach(function(togbtn) {
      if (togbtn == tool) {
        togbtn.attr("checked", true);
      else {
        togbtn.attr("checked", false);
  }  //end toggleButtonIcon

Thanks for your help.


share|improve this question
I have asked a new question here.… – Mike Long Jun 30 '11 at 15:50
up vote 5 down vote accepted


Set a global variable to hold the "onClick" listener, then disable the listener when the button is disabled.

var identifyListener;

function activateIdentify(){
  if (dijit.byId("tool_identify").checked) {
    identifyListener = dojo.connect(map, "onClick", executeIdentifyTask);
  } else {
share|improve this answer
+1 this is how you should do it. – Derek Swingley Jun 23 '11 at 2:59
Thanks @Stephen Lead, your code solved exactly what I asked for. In the long run I am attempting to integrate an "Identify" button into the Esri Navtoolbar sample by using multiple toggle buttons. Most of the code samples I find just seem overly complex. Any suggestions on how to integrate the added block of code with your previous suggestion. I have also updated the sample at the link. – Mike Long Jun 27 '11 at 18:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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