Hey all,
I have a map service that currently has multiple layers. I would like to be able to have all of these layers turned off by default, and then allow the user to turn on whichever layer they would like, and then be able to select this layer, which is then used as the clipping geometry in a geoprocessing task. Right now in my code I am able to select a layer, by creating a query task and then hard coding the layer I want to query:
var queryTask = new esri.tasks.QueryTask("TheURLwhereMyLayerIs/MapServer/1");
This problem is, when I have multiple layers within a map service, I want this line to change so that I will be querying whichever layer is turned on in the map service, not just some layer that I have hard coded. So the two things I need to figure out, how can all of the layers in the map service be turned OFF by default, and how can I insert the name of the layer which is turned on into this line for the layer that should be queried in the query task? Any help would be much appreciated! Thank you!