Make Measure Widget Temporarily Disable other map.on("click") events?

670
2
02-11-2014 07:39 AM
JonathanHouck
New Contributor III
Hi everyone,

Is there a good way to temporarily disable my other map.on("click") events when one of the functions of the dijit measure widget is active? 

The default behavior of my application is to do an identify on click, and I've got some marquee select tools working in conjunction with the draw toolbar, but for some reason when the measure area tool is active, for example, it tries to fire my identify at the same time, which cancels out of the measure tool. 

Is it possible to assign a map.on event to a variable and set it to false? I also noticed there's no measure-start event on the widget.

Any help would be greatly appreciated, thank you!

Jon
0 Kudos
2 Replies
JamieSimko
New Contributor III
I don't think it is possible to set a variable to false to ignore the click events. There are a couple things I think you could do though:

1. Create your own boolean that gets set to true when measure becomes active (false on deactive) & add an if statement to your identify click handler

2. Create setup/teardown functions for each tool that get called before you start drawing on the map. These will:

  • setup: create an event listener and store a reference to its disconnect function (this is returned when an event listener is created)

  • teardown: use that listener's return function to remove the listener

0 Kudos
LuciHawkins
Occasional Contributor III
Hi,

I had the same problem with my identify routine.  I added the code below that checks to see if the measurement widget is being used before proceeding with identify.  I got it from an example and it works well.

function runIdentifies(evt) {
measureMode = dojo.query(".esriButton .dijitButtonNode").some(function(node, index, arr) {
  if (node.childNodes[0].checked) {
   //at least one of the measure tools is active so disable identify
   return true;
  }
});

if (!measureMode) {
                   ...rest of the code follows..


Hope it helps.

Luci