jsn

how to get the list of layers in a map (map service)

Discussion created by jsn on Sep 6, 2013
Latest reply on Sep 18, 2013 by jsn
Hi all

I customized this sample pointing "basemap" to one of my local map services that has several layers

http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jssamples_start.htm

The function getMapLayers  shows only one layer not all of them.

function getMapLayers() {
        alert(myMap.layerIds.length);
        for (var j = 0, jl = myMap.layerIds.length; j < jl; j++) {
            var currentLayer = myMap.getLayer(myMap.layerIds[j]);
            alert("id: " + currentLayer.id + ", visible: " + currentLayer.visible + ", opacity: " + currentLayer.opacity);
        }
    }

Is there any other sample that list all the layers in  map service and  adds them to a drop down box

thanks

Outcomes