AnsweredAssumed Answered

using layer name instead of layer id

Question asked by sskelton on Jan 11, 2011
Latest reply on Oct 16, 2018 by irtiza
I'm a real newbie and have a web app that embeds an ArcGIS map using the JavaScript API. I used the sample code from the following and have my app working:

http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html

If you visit the URL above, you'll see it uses layer ids for the default layers to be displayed (i.e., "imageParameters.layerIds = [2];" and "visible = [2];"). I currently have mine set to use layer ids, but I needed more than 1 layer displayed by default, so I currently have: "imageParameters.layerIds = [0,1,20,21,22];" and "visible = [0,1,20,21,22];".

However, over time, the layer order will change because I'll be adding new layers. Therefore, I want to refer to the layers by name, instead of id.

How do I modify the code at the sample URL above to set the default layers to display using layer names, instead of layer ids?

Thanks,
Steve

Outcomes