Select to view content in your preferred language

How to know type of a layer?

800
2
09-12-2013 04:00 AM
Pankajroy
Emerging Contributor
Hi All,

Using java script API I need to iterate through the layers of map and depending on the type of layer, need to perform certain actions.
Can anyone tell me how to know the type of layer, whether it is a tiled, dynamic, WMS  etc.

Thaks in advance
Pankaj Roy
0 Kudos
2 Replies
JasonZou
Frequent Contributor
Try:

switch(layer.declaredClass) {
 case "esri.layers.ArcGISDynamicMapServiceLayer":
 case "esri.layers.ArcGISImageServiceLayer":
 case "esri.layers.WebTiledLayer":
...
}
0 Kudos
ZachLiu1
Deactivated User
Hi, each layer (actually most esri classes do) should have a "declaredClass" property.
So you can try call:
layer.declaredClass

to see the type of the layer.

the returned value would be like:

"esri.layers.ArcGISDynamicMapServiceLayer",
"esri.layers.WebTiledLayer",
...
0 Kudos