[GIS] How to update a Vector layer with WFS protocol, after updating the filter

openlayers-2wfs

I am using a Vector Layer with WFS protocol to show only a subset of the data. The filter which defines the subset, changes dynamically from the code. How do I refresh the layer, to show only the data that satisfies the new filter?

layer.refresh(); does not work.

Best Answer

If your vector layer is called wfslayer, use the the force option on the refresh method like this:

wfslayer.refresh({force: true});