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.

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
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 '12 at 18:39

2 Answers 2

@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

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

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.