It looks to me that I cannot mix WMS and vector layers' order in OpenLayers 2.

I have an ordered map.layers object and assign z-index values to the layers based on order in the object, for example, map.layers[20] has a higher zIndex than map.layers[19] but lower than map.layers[21].

Yet, if map.layers[20] is a WMS layer and the others are not, the WMS will appear at the bottom on the map, when rendered. The only way to make WMS layer appear on top is to actually setting its zIndex to the highest value on map.layers. Orders between other types of layers are respected and they overlay correctly.

Is it possible to mix WMS and vector layers at all? Or have all the WMS layers to be under all vector layers uncondicionally?

Based on How to define layer order in Openlayers? I manually reordered the whole map.layers object and still it seems to not to work, even if I can check that layer.div.style.zIndex is the theoretically correct for every single layer, and yet that value seems to not be respected when rendering.

  • did you unset isBaselayer in your WMS layers? by default it will be true. – Ian Turton Aug 2 '16 at 13:09
  • Yes, actually base layers work fine since they are ok at the bottom of the stack. I manually set their zIndex to 1 (all of them to 1, since only one of the can be visible at the same time). – arkaninger Aug 2 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.