GetLayerByName

213
1
07-27-2011 01:07 AM
AlaaB__Rasheed
New Contributor
Hello everybody,

Did anyone wrote a function to get a layer from map service (dynamic or tiled) by its name not by its ID ?

Alaa B. Rasheed
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
Did anyone wrote a function to get a layer from map service (dynamic or tiled) by its name not by its ID ?

I am not sure what you call the layer name.
You should be able to get the layer you need by looping on the Map layers.
For example to get the layer having a specified MapName, you can get it by code like:

var myLayer = myMap.Layers.OfType<ArcGISDynamicMapServiceLayer>().FirstOrDefault(l => l.MapName == "SpecifiedMapName");
0 Kudos