Accessing Map service info?

1067
13
08-18-2010 07:37 AM
AndrewEgleton
New Contributor III
Hi,

I'm trying to read the visible status of individual layers in a map service at start up so I can set if they are visible or not, but I am having no luck accessing the Map Service Info, here is my code:

 // Get indexes of visible layers
 AGSMapServiceInfo *dynaServiceInfo = self.dynamicLayer.mapServiceInfo;
 AGSMapServiceLayerInfo *dynaLayerInfo;
 NSMutableArray *visibleLayers = [NSMutableArray arrayWithCapacity:[dynaServiceInfo.layerInfos count]];
 for (int i = 0; i < [dynaServiceInfo.layerInfos count]; i++) {
  dynaLayerInfo = [dynaServiceInfo.layerInfos objectAtIndex:i];
  if (dynaLayerInfo.visible == YES) {
   [visibleLayers addObject:[[NSNumber alloc] initWithInt:i]];
  }
 }


My AGSMapServiceInfo object is always empty, but I'm not sure what I'm doing wrong. I've also tried directly accessing the layerInfos, and creating an array from them with no success either.
Any help appreciated.

Andy.
0 Kudos
13 Replies
KOLDODUARTE
New Contributor
Thanks Nimesh,

Now Its OK!

BR,
Koldo
0 Kudos
DarrenMackiewicz
Occasional Contributor
OK. This post incorporates many different versions of the API, etc.
I just tried to follow this and my head is spinning.

Nimesh, can you please piece this together and show us how in the most recent API I (we) can get access to the current layers that are visible and drawn on the map in a map service. (not the default visible property on the layer).  I would be VERY appreciative of this.
Thanks!
0 Kudos
NimeshJarecha
Esri Regular Contributor
Here is how you should get the information of current visible dynamic map service layer,

- Get all layers in map from AGSMapView::mapLayers.
- Loop through all the layers and check the type of AGSLayer as AGSDynamicMapServiceLayer.
- Get the current visible layers indexes from AGSDynamicMapServiceLayer::visibleLayers.
- if you want more information of that layer then pass index in the AGSDynamicMapServiceLayer:: mapServiceInfo::layerInfos. You'll have AGSMapServiceLayerInfo.

Hope this helps!

Regards,
Nimesh
0 Kudos
DarrenMackiewicz
Occasional Contributor
Thanks for the clarification! I'll give it a try and report back.
0 Kudos