How to set the display order of layers?

3078
5
Jump to solution
10-29-2014 09:09 AM
JasonCantrell
New Contributor III

I have a map on which I'm displaying some graphics layers and some WMS layers.  Some of the WMS layers seem to be displaying on top of the graphics layers (and blocking the graphics from view). I would like to make the graphics layers display on top of all other layers. Is there a property that I can use to make this happen?

I already tried setting the Z value for the layers (set the WMS layers at z=0, and the graphics layers at z=20) and that didn't work. Any other properties that might make this happen for me?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jason,

   If you are adding the WMS layers in code using map.addLayer  and you are not specifying an index in that function then the documentation states:

public function addLayer(layer:Layer, index:int = -1)

index:int (default = -1) — The location for placing the layer. If index is less than 0 or greater than the total number of layers, the layer will be placed on the top.

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Jason,

   You can add layers to the map specifying their index.

map.addLayer(layer:Layer, index:int = -1)

0 Kudos
JasonCantrell
New Contributor III

Thanks for the quick reply Robert. I have a couple follow up questions.

Does each layer have to have a different index (or can I make a group of them have an index of -1, and the group I want to display on top be index=1)?

Also, how to I specify the index if I'm defining the layer in mxml?

ie. <esri:GraphicsLayer id="myGraphicsLayer" symbol="mySymbol" />

I tried adding the index to my graphics layers that I have defined in mxml, and that results in a compile error ("Cannot resolve attribute 'index' for component type com.esri.afg.layers.GraphicsLayer.").

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   If you are defining your layers in mxml than the order they are in your mxml sets their index in the map. Using the map.addLayer is only for adding a layer from ActionScript.

0 Kudos
JasonCantrell
New Contributor III

So my graphics layers are defined in mxml at startup, and I am adding WMS layers during runtime as needed. In this case, should my graphics layers already be showing up on top of the WMS layers?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

   If you are adding the WMS layers in code using map.addLayer  and you are not specifying an index in that function then the documentation states:

public function addLayer(layer:Layer, index:int = -1)

index:int (default = -1) — The location for placing the layer. If index is less than 0 or greater than the total number of layers, the layer will be placed on the top.

0 Kudos