[GIS] Select features of layer which is not on top in OpenLayers

geoserveropenlayers-2wfs

I have posted this question before on the general StackOverflow forum:
https://stackoverflow.com/questions/16278569/select-features-of-layer-which-is-not-on-top

In short my problem is that I have a baselayer, an overlay layer and a WFS layer in OL.
The base and overlay layers are WMS using GWC in GeoServer.
I want to select a feature of the WFS layer but KEEP the overlay layer on top.

By binding a selectFeature control to the WFS layer moves the layer on top.
Using

map.setLayerZIndex(overlayLayer, map.Z_INDEX_BASE["Feature"]+10);

I move the overlay layer back.
But now I can no longer select a feature of the WFS layer.

Adding the overlayLayer to the SelectFeature control doesn't work because it is a WMS layer.

How can I select a feature on the WFS layer which is not on top?
I've tried the GetFeature control, but that requires a roundtrip to the server and I don't want.

I've made an sample of my problem at http://www.smartdakscan.nl/webapps/assen/selectFeature.html

Any help is much appreciated.

Best Answer

Use setLayerIndex instead setLayerZIndex which is a "private" method. Using the setLayerZIndex you simple change the z-index of the DOM elements but not the position of the layer within the map's layer stack.

Once you have ordered the layers as you want, you are right using the SelectFeature control passing the desired layer (WFS) where to select features.

Cheers.