How to retrieve layer name and field name directly from REST endpoints

471
3
06-22-2011 06:28 AM
nidhiarora
New Contributor
Hi ,

I have a dynamic map service which at any time can contain n number of layers . I need to read the layername and attribute information of each layer thru the rest end points ?

Any suggestions about how to achieve this functionality will be highly appreciated.

regards,
Nidhi Arora.
Tags (2)
0 Kudos
3 Replies
JustinRobinson
New Contributor III
Hi Nidhi,

You can use the layerinfos of the ArcGISDynamicMapServiceLayer class. For my implementation:

var layerInfos:Array = ArcGISDynamicMapServiceLayer(<service>).layerInfos; //where service is the name of the map service 
var layerNames:Array = [];

for each (var layerInfo:LayerInfo in layerInfos){
      if (layerInfo.name){  // If the layer has a name
          layerNames.push(layerInfo.name);
      }
}


This would populate layerNames (an array) with the name of every layer of the given <service>. There are a few attributes to the layerInfo, including id, max and min scales, parent layer ID and sublayer IDs.

This is using the Flex API and not getting the information directly from the rest endpoint, however, hopefully is what you're after...
0 Kudos
EokNgo
by
New Contributor III
The info you need should be retrievable using this REST method:
http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/layers.html
0 Kudos
DasaPaddock
Esri Regular Contributor
If you're using AGS 10 and you need more information than is included in LayerInfo and you want to get it in one request for all of the layers in a service, see:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/supportClasses/AllDetails.html
0 Kudos