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 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

share|improve this question
Where do you serve your wfs layer? geoserver, arcgis or sth. it all dependens on serving structure... – Aragon May 18 '12 at 8:49
please post the code you have tried so far and what is not working for you – iant May 18 '12 at 9:43
up vote 2 down vote accepted

Where is somethin like

var wfsLayer = new OpenLayers.Layer.Vector({
    protocol: new OpenLayers.Protocol.WFS({
        url: '',
        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?

share|improve this answer
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 Aug 3 '12 at 7:38
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 Sep 29 '12 at 16:33
thanks again, i now style the vector layer using openlayers stylemap and use wms layer for legend. – neogeomat Oct 1 '12 at 7:28

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.