Select to view content in your preferred language

Creating feature layer by name

579
1
09-10-2010 01:21 AM
LukeEvans
Emerging Contributor
I've got a requirement to add a feature layer to a map by being given the name of the layer.  All layers will reside on the same feature server.  Is there any way to go through all of the layers on a feature server to find the one with the correct name, create this as a FeatureLayer and add this to the map?

The only other alternative for me right now (that I can think of) is to have the layer number and name defined in my config.xml and use this as a lookup when I need it.  Ideally I'd just have the server URL and be able to get the layer by name somehow.

I hope my explanation isn't too gibberish
Tags (2)
0 Kudos
1 Reply
DasaPaddock
Esri Regular Contributor
You can create a ArcGISDynamicMapServiceLayer outside of a Map whose url is pointing at the MapServer and add a load listener to it. Once it loads, all the layers should be in the layerInfos Array. Each LayerInfo includes the name and id which you can then use to build the url for a FeatureLayer inside either the same MapServer or the corresponding FeatureServer.

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/ArcGISDynamicMapServiceLayer.html#l...
0 Kudos