Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have posted this question before on the general StackOverflow forum: http://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.

share|improve this question
I'm confused. You want to select something on the WMS layer (which is just an image), but you don't want to do a round-trip to the server to get a new image with the item selected when you select something? –  René Wolferink May 1 '13 at 13:28
Do you want to just display information about the feature or do you also want to show it highlighted? –  Jamie May 1 '13 at 13:35
I want the WMS layer on top. It is just a non-solid polygon with a house number (grouped layer from GeoServer). But I want to select a feature on the WFS layer. I want to highlight the feature and show its information. The selection is working OK if the WFS layer is on top, but I want the WMS layer to be on top. –  Paul Meems May 2 '13 at 6:27
why do you want the WMS on top? being a non-solid polygon it should be visible also beneath the WFS layer (using it as a transparent image) –  Gery May 17 '13 at 10:23
@Gery: You are right. But my non-solid WMS also has a label which falls beneath my solid WFS. –  Paul Meems May 18 '13 at 11:46

1 Answer 1

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.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.