AnsweredAssumed Answered

Loading all layers in a service

Question asked by nobleach on Dec 14, 2013
Latest reply on Dec 17, 2013 by nobleach
I have an ArcGIS online account with several services. I can get a list of all services by hitting this URL:<myId>/ArcGIS/rest/services?f=json

From there, I can loop over the urls and load a feature service from each by appending '/0' to the URL.

The only problem is, some of those services may have up to 4 layers a piece. Adding a '/0' will obviously only load the first. As it stands right now, I have to make another call to each service, look at the layers key in the returned JSON and formulate a URL for each layer, load it, and then iterate onto the next service. This is extremely costly as it uses a loop inside of a loop.

Is there another method to either load ALL layers from each service? Is there some other method I should be using? My finished product will have a legend widget which will allow toggling layer visibility, so I would like to retain the hierarchy of service->layer(s) so that I could have a checkbox to toggle all layers in a particular service.