I'm writing a custom legend, one that looks and functions just like the silverlight legend. I have everything working except the order of the layers. How can I get the order of the layers in the map?
From what I can figure out, there are two properties on the Map that give the layers in the map. Those properties are Map.layerIds and Map.graphicsLayerIds but there is not a single property that gives the order of the map layers. I don't know how to tell if a graphics layer was added before or after a given non-graphic layer. I know I can add a Map.on('layer-add', function(args){..}); but I am hoping not to do that as I cannot guarantee the map is assigned to the legend before layers are added. How can I get the order of the map layers?
Any help would be great!