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?
Answer
Setting the z-index for each layer should help: http://www.openlayers.org/dev/examples/ordering.html
EDITED
The example I originally linked to isn't too helpful. You want to set the layerindex/z-index of the layers, not the makers within the layers (as the ordering example showed). I put together an example (based off this example) showing custom layer indexing. Notice that when you turn on the Canada Raster, the Marker layer stays on top.
Here is the relevant code:
map.setLayerIndex(dm_wms, 0); //set the image overlay to the bottom
map.setLayerIndex(markers, 99); //set the marker layer to an arbitrarily high layer index
The documentation for the setLayerIndex code is here: http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.setLayerIndex
No comments:
Post a Comment