query multiple layers at once

5259
4
04-12-2011 07:44 AM
SaugatJoshi
New Contributor
How can I query multiple layers from the same program. For eg: I have 10 layers published in the ArcGis server (layer0, layer1......layer9), and I have all the layers turned on in the flex viewer. Now I want to click on the feature to display the attributes. Do I need to set up 10 QueryTask for this like....

<esri:QueryTask id="queryTask"   url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..." />
<esri:QueryTask id="queryTask"   url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..." />
.
.
.
<esri:QueryTask id="queryTask"   url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..." />

Is there any other method or flex sample I can refer which queries simultaneously?

Thank you.
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
SaugatJoshi
New Contributor
Thanks Bob, for the reply. I did go in the FindTask direction and looked at its API. I believe it needs to have a "search text" against which the layers are checked for. My aim however is to click on the map and get the attribute pertaining to it.
1. Do you think I can replace the search with mouseclick event and it still works?
2. How can I know from the application the total number of layers published in the server as we still need to give the layerIds field for the layers to be searched?

Something like "Realted record" we have in the sample but with multiple layers in it.
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=FeatureLayerQueryRelated
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Saugat,

1. The find task does not work with anything other than a string.
2. You would loop through the mapservices in the map  and use the visibleLayers property of say the ArcGISDynamicMapServiceLayer. The layerIds  property is not necessary if you want to search all the layers of a mapservice though.

Now I want to click on the feature to display the attributes.


Maybe the Identify Task is a better match.
0 Kudos
SaugatJoshi
New Contributor
Identify Task worded just fine. Thank you.
0 Kudos