Select to view content in your preferred language

How to know subLayer???s visibility for a layer in a ArcGISTiledMapServiceLayer?

914
1
06-16-2011 01:08 PM
ShenglinXu1
Deactivated User
How to know subLayer???s visibility for a layer in a ArcGISTiledMapServiceLayer.
I know we can get layers from a ArcGISTiledMapServiceLayer by its Layers property.
That is we can get a LayerInfo array. From each layer in the LayerInfo array, we can get the layer???s subLayer ids  if any.
However, I could not find a way to access those subLayers. For example, how to know their visibilities.


ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer titleSerLayer = sLyer as ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer;
if (titleSerLayer != null)
{
ESRI.ArcGIS.Client.LayerInfo[] layerInfoArray = titleSerLayer.Layers;
       foreach (var lyr in layerInfoArray)
       {
                int[] subLayerIDs = lyr.SubLayerIds;
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
That is we can get a LayerInfo array. From each layer in the LayerInfo array, we can get the layer�??s subLayer ids if any.
However, I could not find a way to access those subLayers. For example, how to know their visibilities.


You can use the DefaultVisibility property of LayerInfo (http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.LayerInfo~...)

That gives you the default visibility of a sublayer which is the current visibility knowing that the sublayer visibilities of a tiled layer can't be changed.
You have to take care that if the default visibility of a layer is true, that implicitely means that all its sublayers will be visible whatever the default visibility of these sublayers.
For example, if your ArcGISTiledMapServiceLayer has this sublayer hierarchy:
    - ArcGISTiledMapserviceLayer -> SubLayer1 -> SubSubLayer1 -> SubSubSubLayer1

SubSubSubLayer1 will be visible if SubSubSubLayer1 or SubSubLayer1 or SubLayer1 has a DefaultVisibility set  to true.

From 2.2 you can also directly use 'GetLayerVisibility(subLayerID)' which is going up the sublayer hierarchy for you.
0 Kudos