Getting names and IDs of layers in an AGSDynamicMapServiceLayer

2296
5
07-06-2011 10:17 PM
RobertMartin2
Occasional Contributor II
Hello,

I am trying to create an NSDictionary of layer names and IDs contained by an AGSDynamicMapServiceLayer. I've tried using the visibleLayers property, but the NSArray it returns is null. (I know this isn't the case, however, since my map view is being drawn correctly). Am I going about this the wrong way?

Thank you in advance,
Robert Martin
0 Kudos
5 Replies
JeffPapirtis
New Contributor III
See this thread I started.  It may do what you need.

http://forums.arcgis.com/threads/33344-Dynamic-Populating-list-of-available-Layers

This should return a dictionary of array's and then you can populate your array based on the key in the dictionary.


Jeff
0 Kudos
NimeshJarecha
Esri Regular Contributor
Robert,

All map service layers (Tiled and Dynamic) has property "mapServiceInfo" of type AGSMapServiceInfo. The AGSMapServiceInfo has layerInfos property which has all information of available layers in the map service and their default visibility as an array of AGSMapServiceLayerInfo objects.

You'll get IDs and Name of layer from AGSMapServiceLayerInfo.

Regards,
Nimesh
0 Kudos
RobertMartin2
Occasional Contributor II
Thank you for the responses. @njarecha: Part of the problem may have been that I was trying to access the layers from mapViewDidLoad, but the dynamic service layer had not yet loaded. I tried adding an empty while loop to wait for the property 'loaded' to become true, but this seemed to prevent the map view from being displayed. I can't find any delegate methods for AGSDynamicMapServiceLayer... how are we supposed to know when it's loaded?

Thank you again,
Robert
0 Kudos
NimeshJarecha
Esri Regular Contributor
Robert,

You should use the AGSMapViewLayerDelegate's mapView:didLoadLayerForLayerView: method. This will fire for all the layers you are loading in the mapView. You can check the type of layer to be AGSDynamicMapServiceLayer and then build your sublayer list.

Hope this helps!

Regards,
Nimesh
0 Kudos
RobertMartin2
Occasional Contributor II
That's perfect. Thank you!
0 Kudos