Let me see if I follow.You have two identify tasks, one triggered by a map click at all times and one triggered by a button then a map click, correct?Since both are triggered by a map click, in the map click handler you check to see what state you are in?Something like
connect.connect(map, 'onClick', function(e){
if (ID_STATE = 'DEFAULT') {
// execute =idtask1
} else if (ID_STATE == 'BUTTON_CLICK') {
// execute idtask2
}
});
Does each identify task have it's own handler or are you passing the same handler function to each Identify Task?If you need to process the results differently, then yes you would need to do the same, but if that's the case, then I suggest a different handler per Identify Task.But, if you are handling your clicks this way, might a suggest a different method. This actually has worked since the API moved to Dojo 1.7, I just didn't have a real need for it until earlier this week.Dojo has a dojo/on method that works on all dom events. Since the map is a dom element and has a click event, this will work.http://dojotoolkit.org/reference-guide/1.8/dojo/on.htmlHere is a sample working with a maphttps://gist.github.com/4542944So in your case you could do something like this.
var handler1 = on.pausable(map, 'click', function() {
// stuff
idtask1.execute(/*stuff*/);
});
on(button, 'click', function() {
// here's the cool part, this event only happens one time
var id_handler = on.once(map, 'click', function() {
idtask2.execute(params, function() {
/** handle results **/
handler1.resume(); // turn the default map click handler back on
});
});
});
Add in an error handler to resume default map click events and you are good to go.