Finding service layer 'declaredClass' property (type) in AMD?

905
3
Jump to solution
07-01-2014 08:06 AM
by Anonymous User
Not applicable
I've found numerous threads discussing 'layer.declaredClass' as a way to get to the type of service for a layer in a map (e.g. ArcGISDynamicMapServiceLayer, FeatureLayer, etc.).

The only documentation linked was to a Dojo widget's class, so I am unsure how to work this on a map layer. I tried simply using layer.declaredClass but it was undefined. The API documentation doesn't seem to mention this property, and the only service type with a 'type' property is FeatureLayer. Any help appreciated!

Related threads:
http://forums.arcgis.com/threads/98523-Print-Task-on-Custom-ArcGISImageServiceLayer
http://forums.arcgis.com/threads/48137-Dynamically-detecting-map-layer-service-type
0 Kudos
1 Solution

Accepted Solutions
JeffPace
MVP Alum
I have seen layer.declaredClass as well, but usually for custom objects.  you could try instanceof

 if ((this.rootLayer instanceof (ArcGISDynamicMapServiceLayer) ||       this.rootLayer instanceof (ArcGISTiledMapServiceLayer)))


you could also

console.dir(layer) 


and sniff the properties in Firebug to see if there is a declaration somewhere

View solution in original post

3 Replies
JeffPace
MVP Alum
I have seen layer.declaredClass as well, but usually for custom objects.  you could try instanceof

 if ((this.rootLayer instanceof (ArcGISDynamicMapServiceLayer) ||       this.rootLayer instanceof (ArcGISTiledMapServiceLayer)))


you could also

console.dir(layer) 


and sniff the properties in Firebug to see if there is a declaration somewhere
by Anonymous User
Not applicable
Thanks Jeff - 'instanceof' is a great solution. Just to be clear, that is a JavaScript operator, not a part of the esri JavaScript API correct? Very cool, I'm pretty new to JavaScript still.
0 Kudos
JeffPace
MVP Alum
correct it is pure javascript
0 Kudos