Hi all.
Was wondering if there's a working sample or an easy way to just kill all the click handlers for the "map" object, at once. Nuke it from orbit, so to speak.
(i.e. Measure, Identify, Pictometry, Editor, etc all competing). I know how to do them one by one for each different tool but it gets tedious, long and confusing. There should be an esri method on the map object to remove all non-standard handlers (i.e. not counting pan, zoom, dbl click) although I am not aware of one. Didn't see any in a search. But I was wondering if perhaps someone has wired up such a pattern already? As of now I am mucking through trying to keep them from fighting each other one by one. Perhaps something from the dojo or jquery world will help? Hopefully this concept would not affect the standard nav handlers like mousewheel zoom in/out or doubleclick. Perhaps they would have to be explicitly avoided, to preserve these.. not sure how to do it, yet, so I'm wondering if someone else has?
Thanks!
This is a good question. At the moment I turn them off immediately after they have been used.
Tim, good call. That'll work. So glad to have the braintrust here to bounce ideas off. That will do the trick indeed!
I still believe ESRI should consider adding this very nice feature / concept into the API officially. An official method to both remove all click handlers from the map object (including navigation functions like pan and zoom and double click), and an option to remove just non-standard click handlers, i.e. ones we add but not including navigation handlers built-in. I guess there would have to be a system to "register" our handlers in order for this to work... Still, I think it's worth adding to the API, anyone else? Plus, ESRI can release a nice working sample, if they do choose to add it!
It would be a good idea. It is very annoying when your app has popup windows for feature layers and you try to meassure etc...
Yeah. For my last site www.sagis.org I tested on each tool, to see if other tools were active and if so to kill them. And to test if measure is currently active use this snippet:
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) {
///do some stuff only when Measure is not active, such as Identify
}; //end of if test for measurement being active
For other handlers I test like if (Pict === undefined || Pict === false) {
where Pict is Pictometry click handler.
This thread while dated and pre-AMD looks helpful and I will investigate this and post results if successful..
I'll check it out!
The editor tool and the geocoder had a conflict. If I tried to find an address, the editor tool would display a pop-up. If I tried the editor first the address tool would display the editor, but I wrote about a work around in a series I am writing for starter tempates and both widgets are working fine now; if your interested, here is the work around: Adding an Editor to the Template