This applies to ArcGIS Server 9.3 with the JavaScript API 2.4.
My goal is to click on the map and have the Identify task run on all visible Dynamic layers.
IdentifyTask requires a URL to the REST endpoint, with IdentifyParameters specifying which layerIds the identify operation should be performed on.
It seems the Identify tool is expecting all layers to be accessible from the same REST endpoint (ie, the same ArcGIS Server).
In my case, layers are being served from multiple ArcGIS Server instances – how can the Identify tool support this? For example, if the Buildings and Parcels layers in this map were coming from separate ArcGIS Servers.
(This is related to my previous question, but I realise now I need to answer this question first)
Best Answer
First, here is a simplified JavaScript API example to show the concept of using DeferredList to process multiple identify tasks:
Then here is an example in jsFiddle that I think does what you want, runs using all visible layers in all visible dynamic map layers in the map.
http://jsfiddle.net/blordcastillo/mULcz/
All typos are fixed now :)
The basic idea is that whenever the map is clicked or visibility is toggled, the identify is rerun. When the identify is run, the number of identity tasks fired depends on the number of layers visible, and it waits until all layers return to display its results.