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?


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.

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.