Good morning,
I'm wondering if there's an easy way to get the layer types for all the layers in a map service. By layer "type" I mean: Group Layer, Raster Layer, Annotation Layer, Annotation SubLayer, Feature Layer, etc..
When I check the layerInfos array of my ArcGISDynamicLayer, it will tell me the layer id, parent id, etc.. but it won't tell me what the layer type is. I know I could create a FeatureLayer for each layer to get this info, but that would generate more then a hundred requests since the map service has several layers.
My goal is to get a list of all the layers with the "Feature Layer" type in the map service.
Thanks,
Yohan
Solved! Go to Solution.
Rather than multiple queries, you can use a single query to the All Layers and Tables REST API endpoint.
Yohan,
I do not think there is any other way then to submit a esriRequest to each of the sublayers in the map service and check the response type for each result. There is no need to create a FeatureLayer for each when you can use esriRequest to just get the json response from the layer with will include the type.
Here is a thread that has a sample that uses esriRequest: List ArcGIS Server Services and URLs to Services
You're right about not needing the FeatureLayer of course. I confused this part with another requirement we have in our code to get the feature layer fields for some specific layers.
So since this is the way to do it, I tried your suggestion and I think it will do. It's a lot of requests but I didn't notice any significant difference (performance wise) when we load the web app. Plus the requests are cached and will return 304 when it's been done once already. It pollutes the Network tab a bit, but that is a minor issue.
Great
Thanks Robert
Rather than multiple queries, you can use a single query to the All Layers and Tables REST API endpoint.
Jeff,
Great idea, I forgot about that.
Works like a charm, and makes the code cleaner too since:
1) Each layer object has a property for the object of it's parent layer, instead of just the id.
2) No need to check if this is the last request before calling my callback function, since there's only one request
Thanks Jeff