Hi,
As far as I know, MediaLayer and GraphicLayer do not have "index" attribute, so their display order are determined by their sequences in the layer array of the map.
This does work for among same layers, so if a GraphicLayer (MediaLayer) is added to map after another layer of its same kind, their graphics (elements) would be displayed on top of the ones from the other layer. However, even if a GraphicLayer is added to map after a MediaLayer, the graphic stills display beneath media elements.
Is there a way to control display orders of GraphicLayer and MediaLayer?
BTW, I am using verison 4.28.
Thank you!
Solved! Go to Solution.
Hi @JackyCai ,
MediaLayer and GraphicLayer behave like any other layer and can be placed in any position in the layer's collection. The last layer in the map.layers collection in the top layer in the map. You can use the collection add() method with an optional parameter for the index to place a layer anywhere in that collection.
I created a codepen that shows a graphics layer added after a media layer and the graphics appear on top.
https://codepen.io/sagewall/pen/GRLpmMZ
If you comment out line 262 and uncomment line 264 (where I used the index) you can change the order of the MediaLayer and GraphicsLayer in the collection and the order they appear in the map.
I hope this helps
Hi @JackyCai ,
MediaLayer and GraphicLayer behave like any other layer and can be placed in any position in the layer's collection. The last layer in the map.layers collection in the top layer in the map. You can use the collection add() method with an optional parameter for the index to place a layer anywhere in that collection.
I created a codepen that shows a graphics layer added after a media layer and the graphics appear on top.
https://codepen.io/sagewall/pen/GRLpmMZ
If you comment out line 262 and uncomment line 264 (where I used the index) you can change the order of the MediaLayer and GraphicsLayer in the collection and the order they appear in the map.
I hope this helps
Thank you for your reply, I am going to check if there is anything wrong in my code and update here.
Yes, it is working perfectly in your demo and mine, there must be something wrong with the layer management in my project. Thanks for the help!