I have one WFS polygon layer and one WFS point layer. The polygon layer has an attribute user_id. The web map has two requirements.

  1. Filter the polygons based on the attribute user_id. That is, a user can only see polygons which are assigned to him. This can be done like this:

    filter: new OpenLayers.Filter.Comparison({ type : OpenLayers.Filter.Comparison.EQUAL_TO, property : "user_id", value : user_id })

  2. Filter the points based on the filtered polygons. That is, a user can only see points within the filtered polygons from step1. I checked the

    OpenLayers.Filter.Spatial.INTERSECTS. it only takes OpenLayers.Bounds || OpenLayers.Geometry.

I have no idea how to achieve this. Please help. Thanks.

1 Answer 1


After your WFS polygon layer (pLayer) has the filter applied and is loaded you should be able to access the pLayer.features property and extract the geometry of each feature. You should then be able to create a multipolygon geometry and use that to filter the points with INTERSECTS.

I did this recently and found that the multipolygon geometry had undesirable effects if the polygons overlapped. In that case, I used the Javascript Topology Suite to create a single merged polygon and use it in the INTERSECTS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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