AnsweredAssumed Answered

How can I get index of the layer order?

Question asked by matrixhazard on Nov 9, 2015
Latest reply on Nov 11, 2015 by matrixhazard

Hi, I'm doing R&D about the map application that can rearrange order layer.

 

For example I add 5 layers according to below sample code

 

 

                    var baseMap1 = new ArcGISTiledMapServiceLayer(urlBasemap1, { id: "BASEMAP1" });

                    var dynamicMap1 = new ArcGISTiledMapServiceLayer(urlDynamicMap1, { id: "DYNAMICMAP1" });

                    var graphicsLayer1 = new ArcGISTiledMapServiceLayer({ id: "GRAPHIC1" });

                    var dynamicMap2 = new ArcGISTiledMapServiceLayer(urlDynamicMap2, { id: "DYNAMICMAP2" });

                    var featuresLayer1 = new ArcGISTiledMapServiceLayer(urlFeaturesLayer1, { id: "FEATURESLAYER1" });

 

                    map.addLayer(baseMap1);

                    map.addLayer(dynamicMap1);

                    map.addLayer(graphicsLayer1);

                    map.addLayer(dynamicMap2);

                    map.addLayer(featuresLayer1);

 

 

But "map" object will keep graphics & features layer ID separately from other layers. Therefore, it keeps each layer id as graphicsLayerIds ("GRAPHIC1,FEATURESLAYER1") and layerIds ("BASEMAP1,DYNAMICMAC1,DYNAMICMAP2")

 

If I would like to get index of layer order as BASEMAP1 --> 0, DYNAMICMAP1 --> 1 , GRAPHIC1 --> 2 , DYNAMICMAP2 --> 3 , FEATURESLAYER1 --> 4, do ArcGIS API Javascript can help me with this or do I have to manually create a config object for these layer order by myself?

 

Thanks

Outcomes