Determine a Layers index in the map

1880
1
06-05-2014 08:04 AM
NigelAlford
New Contributor III
I'm reordering some layers
map.reorderLayer(id,index);
and that's working flawlessly, but I'd like to query against the map object to review the layer order. I see in this method that there is an index associated with the layer id, which leads me to believe I can determine the order of the layers at anytime.
Question: Is there a method to determine a particular layer's order or a property in the map object I could use?

Thanks,
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor
Based on some preliminary testing, using this will give you the list of layers, in order. One caveat is that this will include the base layer(s).

for (var j = 0; j < map.layerIds.length; j++) {
    var layer = map.getLayer(map.layerIds);
    alert(layer.id + ' ' + layer.opacity + ' ' + layer.visible);
}
0 Kudos