map12

Is it possible to Toggle map service layers by name (not id) ?

Discussion created by map12 on Jul 16, 2012
Latest reply on Jul 17, 2012 by sli-esristaff
I need to toggle Dynamic Map service layers by Layer Name instead of Layer id.
Is it possible for me to do this using layerinfo.name?
I have modifed the Explicity Create Map Service Layer List sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/map/map_explicitlayerlist.html for what I need
and I have been having issues trying to get layerinfo.name defined.

I have followed a few example in other posts and can't quite get the samples to work in my favor.
I saw the recent post regarding the 'Legend with Visible Layers' and couldn't figure out how to breakdown that sample to manually build the layer list.
I have attacthed my working sample using Layer id.

One thought I had was to write a function that would take the layer name from the check box function, Get/return the layer id, and use that result to toggel the layers.
I am still developing my javascript skills but would be open to any suggestions.

My ArcGIS server is 9.31 so I can't take advantage of the Legend widget or other samples.
Thanks,
Chris

Outcomes