Select to view content in your preferred language

Layer Index in addLayer(layer, index)

793
0
01-26-2022 02:11 PM
NathanHeickLACSD
Frequent Contributor

I'm using the ArcGIS API for JavaScript v. 3.x and I want to us the map.addLayer(layer, index) function, however, the documentation is fairly weak.  From my experience, I believe it is the index from bottom to top of the layer in all operational layers.  However, I don't see a good function to retrieve the index of a layer.  Since I am programmatically inserting layers into the map and since I have a large number of layers, I need to be able to look up a layer by its ID and get its index.  Is there anything OOTB for this?  Also, is the index for all operational layers or just within map.layerIds or map.graphicsLayerIds?  I notice it's easier to handle in the 4.x API, so I am guessing this is a weakness in the API or my knowledge.

https://developers.arcgis.com/javascript/3/jsapi/map-amd.html#addlayer

 

 

addLayer(layer, index?)

Tags (1)
0 Kudos
0 Replies