How to get the fields in a layer with a ArcGISDynamicMapServiceLayer

3132
5
01-11-2011 05:54 AM
SebastienPelletier
Occasional Contributor
I use a legendcontrol with ArcGISDynamicMapServiceLayer and each layer (LayerItemViewModel object) has no information on the fields.

I want to know how to get the field list of layers contained in a DynamicLayer. Or how to get the FeatureLayerInfo of each layer in a dynamiclayer.
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
The ArcGISDynamicMapServiceLayer has Layers property, which gives you some information about the sublayers.http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGISDyna...

To get fields of each specific sublayer, you will need to perform a query on each sublayer with OutFields = "*", the query URL can be formed by appending the layer.Url and the sublayer.ID.

Or use the query URL and parse the JSON to get "fields" value, similar approach as in the following thread except look at the sub layer's "fields" section http://forums.arcgis.com/threads/17362-how-to-query-map-knowing-map-layer-name-(not-id)
0 Kudos
SebastienPelletier
Occasional Contributor
I want to create a form "Select by Attributes" and I need the fields before creating the query.

As the following site:
http://phldemo.esri.com/SilverlightViewer2/default.aspx?theme=AliceBlue
0 Kudos
dotMorten_esri
Esri Notable Contributor
I suggest you create a FeatureLayer, call initialize, and on initalize grab the info from the layer (no need to add the featurelayer to the map).
0 Kudos
JenniferNery
Esri Regular Contributor
ArcGISDynamicMapServiceLayer does not give you the fields for its sublayers.

You can create a FeatureLayer for every sublayer, if you want or parse the JSON to get "Fields" information.

FeatureLayer has LayerInfo.Fields property http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureSer.... Field contains the following information http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Field_memb.... Note however that the layer need to be initialized before the LayerInfo will have a value.
0 Kudos
SebastienPelletier
Occasional Contributor
Excellent, thank you very much
0 Kudos