I have a map with 3 layers: 1 base layer, 1 overlay and 1 WFS layer. I load them as follows:
map.addLayers([baseLayer, wfsLayer, overlayLayer]);
When the user clicks on the card, he must select a function at the WFS level. So I added a select control after calling map.addLayers:
selectControl = new OpenLayers.Control.SelectFeature( [wfsLayer], { clickout: true, toggle: false, multiple: false, hover: false } ); map.addControl(selectControl); selectControl.activate();
This works great, my functions are selected when clicked.
But my layer with the label is below the WFS level, and I want it to be on top. The overlay layer is an unfilled polygonal layer. Therefore I added
map.setLayerZIndex(overlayLayer, map.Z_INDEX_BASE[ "Feature" ]+10);
after map.addLayers. It looks ok. My labeled layer is now above my WFS level. But when I click on the card, nothing is selected.
Most likely, I am not doing it right. How can I make a layer with an inscription on top and my WFS level can be selected?
[EDIT]
As mentioned by Christoph, I tried
selectControl = new OpenLayers.Control.SelectFeature( [wfsLayer, overlayLayer], { clickout: true, toggle: false, multiple: false, hover: false } );
But this led to an OL error, probably because the overlay layer is a WMS layer.
[EDIT # 2]
I tried this question at https://gis.stackexchange.com/questions/59619/select-features-of-layer-which-is-not-on-top-in-openlayers