1

I face the following problem. I have two vector layers. One has linestring and the other point geometry.

When I add this line to my point geometry vector layer:

          pointLayer.setZIndex( 1001 );

I get the point layer on top and then I am unable to select any feature from the linestring vector layer.

How can I solve this problem so all the features are clickable? I wouldn't expect this behavior as the point vector layer just has some points.

  • 1
    Do you want to select features from only one layer, or both? How did you construct the selection control? Is it the SelectFeature control? – Gabor Farkas Mar 11 '15 at 13:30
  • Yes. I need to select features from both layers. This is how I constructed the feature control for the linestring layer: wfsLinestringLayer.events.on({ featureselected: function(event){.... For the point vector layer I want to add a feature.popup functionality. – user1919 Mar 11 '15 at 13:31
1

To solve this problem, you have to look under the hood of the library. The SelectFeature control can be applied on a single layer or multiple layers.

  • Single layer: The control's layer and handler properties receives the layer object, then you can select features from that layer.
  • Multiple layers: The library creates a new Vector.RootContainer layer, which basically a vector layer group containing the layers. The control is then applied to that RootContainer layer.

This way if you modify the Z index of the original layer, you just block the mouse event from the created layer group. I have two ideas which would help you solve this problem in theory:

  1. Get the RootContainer layer and modify its position to be on top. You can set the Z-index, but the more convenient way is to use the map's raiseLayer function.
  2. Define the pointer-events CSS property of your layers' DOM elements. You can set it to none, to get your mouse clicks fall through completely.

Your Answer

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

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