I am in need of the correct syntax for loading WFS layer using OpenLayers. I have gone through many examples on the OpenLayers site and other examples, but can't figure out how to use the necessary and optional options like strategies, protocols etc

  • 2
    Where do you serve your wfs layer? geoserver, arcgis or sth. it all dependens on serving structure...
    – urcm
    Commented May 18, 2012 at 8:49
  • 1
    please post the code you have tried so far and what is not working for you
    – Ian Turton
    Commented May 18, 2012 at 9:43

1 Answer 1


Where is somethin like

var wfsLayer = new OpenLayers.Layer.Vector({
    protocol: new OpenLayers.Protocol.WFS({
        url: 'http://example.com/wfs',
        featureType: 'myFeatureTypeName',
        featureNS: 'topp',
        geometryName: 'the_geom'
    strategies: [ new OpenLayers.Strategy.BBOX() ]

getting you? Can you see any GetFeature-Request in Firebug or Inspector? Have you set up your OpenLayers.ProxyHost variable?

  • thank you Crischan, now i have a wfs layer, i have 1 more question. the layer i am retriving has a sld file attached to it. so that, in same wms layer i get a legend. but in wfs layer i don't get legend/
    – neogeomat
    Commented Aug 3, 2012 at 7:38
  • 1
    I don't think there's a legend control for WFS in OpenLayers. WFS+SLD would be WMS (roughly speaking) and for OpenLayers WFS is purely a vector data source with no knowledge about any styles attached to it by your WFS server software.
    – Crischan
    Commented Sep 29, 2012 at 16:33
  • thanks again, i now style the vector layer using openlayers stylemap and use wms layer for legend.
    – neogeomat
    Commented Oct 1, 2012 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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