Hello everyone. First of all excuse me if I do something wrong but´s the first time I ask something in a forum, i´m kinda newbie...
My problem is that I have a project with a ArcGISDynamicMapServiceLayer and this service turns on and off the layers according to the scale. I want to get a string of all the layers that are visible at a determined moment, for example, I´m looking at the map at an x scale, I click a button and I want to see the layers that are on at that moment.
Is this possible? So far I´ve tried with the following code but I get all the layers, not only the ones that are visible:
private void getListOfVisibleLayers()
{
string visibLayers = "";
StringBuilder sbVisibleLayers = new StringBuilder();
sbVisibleLayers.Append("&layersVisib=");
ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer serviceLayer =
(ArcGISDynamicMapServiceLayer)MyMap.Layers["PAE"];
ESRI.ArcGIS.Client.LayerInfo[] layerInfoArray = serviceLayer.Layers;
for (int index = 0; index < layerInfoArray.Length; index++)
{
if (layerInfoArray[index].DefaultVisibility == true)
{
sbVisibleLayers.Append(layerInfoArray[index].Name);
sbVisibleLayers.Append(";");
}
}
visibLayers = sbVisibleLayers.ToString();
}
If you have any idea that could help me it would be great, if not, never mind. Thanks for all!