31

I have a marker layer, two vector layers and two raster layers. The marker layer gets covered by the two raster layers.

Is there a way to move the marker layer always on top?

Edited: The order of Z-indexes works well in the vector layer, but when I add another WMS raster layer on the map with a lower Z-index, the raster layer still covers the vector layer.

Edited: Could anyone point out the difference of the rendering order in terms of "LayerIndex" and "Z-Index" of a Layer? I think the layer index deal with the overlay order and the Zindex deals with the feature order in a vector layer, am I right?

Seen
  • 2,205
  • 7
  • 26
  • 37
  • I think layerindex and z-index are interchangeable terms in OpenLayers. They are used in the same context in the documentation, ex: http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.setLayerIndex – Casey Oct 04 '11 at 18:24
  • Hello @Casey I appreciate your example. However, I do not think the layerindex and z-index are interchangeable. For my own experience the setZindex does not work but the setIndex works. I notice that: 1. the Z-index example in openlayer works for a feature in a vector layer, and it is enabled by rendererOptions: {zIndexing: true}. 2.From your example for the raster image layer, you can see the layer render order is based on what you see on the map control, which depends on the layer index (as your answer code). 3. The layer index is set by the order I add on new layer (based layer as 0...) – Seen Oct 05 '11 at 01:52
  • I think you are right. 2 & 3. Right, but you can override the default behavior by calling the setLayerIndex method, which adjusts the z-index of a layer. This will effect the order of the layers in the map control and the drawing order of the layers.
  • – Casey Oct 05 '11 at 02:38