I'm having trouble to add a WFS layer over an OSM map. At first I thought that my data had a problem, and I thus decided to adapt one of the example on the Openlayers website. I have no error returned, but the layer is not appearing... Instead, I see in Firebug that there is a WFS request made to the server, but it is empty


No GET request or arguments whatsoever. I can correctly make the request and I get a xml file as a result (in eg Firefox). I thought it was maybe because of the a proxy and I set one up (the one in Openlayers FAQ), but I get the same thing.

Here is the code I use:

<!DOCTYPE html>
    <meta charset="utf-8">
    <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>

        var map, layer;
            var epsg900913 = new OpenLayers.Projection("EPSG:3857");
            var epsg4326 = new OpenLayers.Projection("EPSG:4326");

        function init(){
            OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
            var cent=new OpenLayers.LonLat(6.59,46.39).transform(epsg4326,epsg900913);

            var osm = new OpenLayers.Layer.OSM("Open Street Map");
            var wfs = new OpenLayers.Layer.Vector("States", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    version: "1.0.0",
                    srsName: "EPSG:4326", // this is the default
                    url:  "http://demo.opengeo.org/geoserver/wfs",
                    featureType: "states",
                    featureNS: "http://www.openplans.org/topp"
                projection: new OpenLayers.Projection("ESPG:4326")

            map = new OpenLayers.Map("map",{
                projection: epsg900913,
                center: cent,
                zoom: 10
            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            map.addControl( new OpenLayers.Control.LayerSwitcher() );


<body onload="init()">
    <div style="width:500px; height:500px" id="map"></div>
    <div id="coordinates"></div>

1 Answer 1


Ok, I've lost several more hours of my life due to my mild dyslexia. The line

projection: new OpenLayers.Projection("ESPG:4326")

should read EPSG...

The proxy is also mandatory. However, quick followup: Why is the request I see in firebug


and not something like

  • are you using POST instead of GET?
    – Ian Turton
    Jun 28, 2013 at 8:28
  • ah, yes, it is a POST request. Is there a way to do a GET instead, to see the difference and tinker with it?
    – Bulkilol
    Jun 28, 2013 at 8:46

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.