Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to select features on a wfs layer using a polygon instead of a box. I was hoping this would be a standard option in the SelectFeature class. Too bad this isn't the case.

Any implementation suggestions?

share|improve this question

You can use the layer.filter property on the vector layer then refresh the layer.

layer.filter = new OpenLayers.Filter.Spatial({
    type: OpenLayers.Filter.Spatial.INTERSECTS,
    value: event.feature.geometry
layer.refresh({force: true});

Here's the Example

Granted this will make all the non-selected layers disappear, but you can possibly do this just to collect the array of features (without refreshing the layer) then use the SelectFeature class to select only the ones the filter returned.

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.