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.

Say I have a vector layer with a couple hundred features, and I just want to operate on a filtered subset of those features, such as those that have a State attribute of "OR".

Am I reading the OL docs correctly that the Filter classes are only for filtering WFS requests? Is there some other way of filtering ordinary features by a specific attribute (e.g. for zooming to the extent of just those features)?

Or do I have to just manually iterate over the features and populate an array of the desired ones? (Not a huge deal, by the way; just wondering if there's a more OpenLayers-y way of doing this).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I iterate all the time and it seems fine as far as speed is concerned. It might be easiest too.

You can also use the filter for other OGC standards such as WMS, GML, and KML.

You can also use it with a filter strategy:


setFilter: function({OpenLayers.Filter})

This will re-evaluate any features on the layer and in the cache. Only features for which filter.evalute(feature) returns true will be added to the layer. Others will be cached by the strategy.


Please look at http://openlayers.org/dev/examples/filter-strategy.js

OpenLayers.Strategy.Filter

share|improve this answer

Your Answer

 
discard

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.