AnsweredAssumed Answered

Get layer order within map

Question asked by on Dec 12, 2014
Latest reply on Dec 15, 2014 by



Does anyone know if there is a way of getting a layers current index / order in the map?  The map has a reorder function where you can pass a layer and an index, but in order to know where I want to place the layer, I need to know the index of the layer I'm moving it above or below.


It occurred to me it might be possible to keep track of the order all layers are added to the map, for example by listing for layer-add type events.  I'm not sure how reliable that would be though and hoped there was a built in mechanism.


Note: I'm not wanting to re-order sub layers within a map service, as per the reorder example here: Reorder layers in map service | ArcGIS API for JavaScript   I want to actually re-order the map service layer itself, relative to other map service layers loaded in the map.