Access Attributes for Sub-Layer Within AGSDynamicMapServiceLayer

2159
2
Jump to solution
03-16-2012 07:27 AM
DavidMarley
Occasional Contributor II
I'm fairly new to the iOS SDK and trying to work through some basic concepts here.  What is the best way to access the attributes (the "attribute table" in old-school GIS terminology) associated with a sub-layer within an AGSDynamicMapServiceLayer?  I am working on an iPad app with a standard split view (map on the right, in detail view; table in left column of split view) where I want to show a set of project locations on the map, and have those projects show as a list in the table on the left. Ultimately I want to have interaction between the map and the table (touch a row in table to zoom to location on map, etc.).  I have the project locations in a feature class, and have that published as a standard AGS Map service.  I have the service/layer loaded into the map as a AGSDynamicMapServiceLayer.

From the documentation, I can see that the AGSGraphic contains an attributes collection, but from the doc it appears I need to run an AGSQueryTask or other task in order to get an AGSFeatureSet containing the graphics/attributes.  Is there a way to get it directly from the AGSDynamicMapServiceLayer that is already in the map?

So I could run a query to return all my records (say with a dummy where clause like "1=1") but this seems like an unnecessary step given that I already have the points on my map.  And if I use a query result to display a graphics layer, then I lose the symbology associated with the layer itself, and have to utilize a client-side graphic to display the points.  This might be OK, but just doesn't seem right when I am wanting to show a feature class in its entirety.

What's the best/recommended approach here?

Thanks in advance,

Dave
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
The AGSDynamicMapServiceLayer you see in a map is nothing but an image of the map. So you cannot get attributes of the features from an image. Hence, you have to execute a query task to get the features as graphics.

Based on your description the best recommended approach would be to load all layers as AGSFeatureLayer and you'll get all graphics in a map with attributes and symbology defined in the service.

Hope this helps!

Regards,
Nimesh

View solution in original post

0 Kudos
2 Replies
NimeshJarecha
Esri Regular Contributor
The AGSDynamicMapServiceLayer you see in a map is nothing but an image of the map. So you cannot get attributes of the features from an image. Hence, you have to execute a query task to get the features as graphics.

Based on your description the best recommended approach would be to load all layers as AGSFeatureLayer and you'll get all graphics in a map with attributes and symbology defined in the service.

Hope this helps!

Regards,
Nimesh
0 Kudos
DavidMarley
Occasional Contributor II
Thanks for the clarification Nimesh.  I had come to the same conclusion about the AGSDynamicMapServiceLayer and have been trying the Query approach - it seems like I can do what I need using query.  The idea of using an AGSFeatureLayer is a good one...I will definitely explore that as well.

Thanks,

Dave
0 Kudos