I am trying to add a WFS Layer with a BBOX strategy. When I change the extent I want GeoServer to return only the features in that extent. Here is the code I am using to add layer.

wfs = new OpenLayers.Layer.Vector("Fields_WFS", {
    strategies : [new OpenLayers.Strategy.BBOX()],
    protocol : new OpenLayers.Protocol.WFS({
    version : "1.1.0",
    url : GEOSERVER_HOST + ":" + GEOSERVER_PORT + "/geoserver/wfs",
    featurePrefix : "rpid",
    featureType : "FIELDS_SUBSET_BNG_OSGB36_1", 
    featureNS : "<URI>",
    srsName : "EPSG:27700" //default
    }),
});

The map is set to a maxextent initially. And I have restricted WFS features to max 100 in geoserver settings.

My problem here is it only shows the same features every time I load and when I move or zoom +- it does not refresh WFS features.

Thanks, JP

link|improve this question

43% accept rate
1  
Have you checked in Firebug/Fiddler what's going out to your server? Try to load the WFS request manually in another tab with the BBOX parms in the URL. Maybe the issue is in your GeoServer config – Vadim Feb 9 at 18:39
feedback

1 Answer

Try this in the layer definition:

 strategies: [new OpenLayers.Strategy.Refresh({force:true}), new OpenLayers.Strategy.BBOX({ratio:2, resFactor: 3})],

works for me.

Also note that by default the BBOX strategy requires that you zoom/pan quite a lot before a new request is issued. Try changing the ratio and resFactor params to lower the threshold.

The explanation for their meaning is in the code.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.