[OpenLayers-Users] filtering WFS layers

Christopher Schmidt crschmidt at metacarta.com
Fri Sep 7 15:10:02 EDT 2007


On Fri, Sep 07, 2007 at 03:11:27PM +0100, David Herbert wrote:
> I have a requirement to apply a property filter to a WFS layer of my map
> e.g:
> 
> <Filter>
> <PropertyIsEqualTo>
> <PropertyName>species</PropertyName>
> <Literal>chinstrap penguin</Literal>
> </PropertyIsEqualTo>
> </Filter>
> 
> for a WFS layer displaying bird colonies.  Looking at the docs at:
> 
> http://dev.openlayers.org/docs/files/OpenLayers/Layer/WFS-js.html 
> 
> leads me to believe a method called mergeNewParams is available, which
> will modify the layer parameters and redraw it.  I am using OL 2.4
> stable.  However, trying to use this method results in "mergeNewParams
> is not a function" errors.  Looking at WFS.js, I see this method is not
> there.  Should it be? If not, what's the best approach to filtering
> layers this way? Should I remove the layer and recreate with new
> parameters? Or is there a better way?

mergeNewParams is only in trunk. But if you're not changing the filtero
n the fly, you don't need to use it anyway: simply add a
'filter':'myfilterstring' in the parameters when you construct your
layer. The parameters are the third argument to the WFS constructor.  

If you do need to do on-the-fly filtering, then you'll need to either go
to trunk, or you'll need to destroy the layer and re-add it with a new
filter when it changes.  

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list