Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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 '12 at 18:39

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.

share|improve this answer
Thanks @unicoletti. Just new OpenLayers.Strategy.BBOX({ratio:2, resFactor: 3} works for me, i.e. I don't need a refresh strategy. – minisaurus Jun 10 at 11:36

@unicoletti's answer is quite right. I try it with my OpenLayers.Protocol.HTTP. And my new added feature in my json file can be loaded after zooming or panning at some extent. Here is my code, hope you can get some ideas.

    var vector_layer = new OpenLayers.Layer.Vector('JSON Vector Layer',{
        protocol: new OpenLayers.Protocol.HTTP({
            url: 'http://localhost:8080/MyServlet/gml/write.json',
            format: new OpenLayers.Format.GeoJSON({})
        strategies: [new OpenLayers.Strategy.BBOX({ratio:2, resFactor: 2}), refreshStrategy] 
share|improve this answer

Your Answer


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.