1

I'm having problems trying to load a Geoserver/WFS vector layer using OpenLayers. I can see GML data loading in Firebug and also I can see the layer name is in the layer switcher but the the data is not rendering. I've added my code below. I've seen similar questions on here that have helped me a lot with this so far but I can't see anything else to make it work.

Can anyone see anything I've missed or done wrong?

    wfs1 = new OpenLayers.Layer.Vector("CamEO Boundary", {
        strategies : [new OpenLayers.Strategy.Fixed()],
        protocol : new OpenLayers.Protocol.WFS({
        version : "1.0.0",
        url : "http://domain.co.uk/geoserver/wfs", 
        featurePrefix : "riversdata",
        featureType : "cameo",
        featureNS : "http://domain.co.uk/riversdata",
        srsName: "EPSG:27700",
        geometryName : "geom"
        }),
        format : new OpenLayers.Format.GeoJSON({
        'internalProjection': new OpenLayers.Projection("EPSG:27700"),
        'externalProjection': new OpenLayers.Projection("EPSG:900913")
      }),
        styleMap: new OpenLayers.StyleMap({
        strokeWidth: 3,
        strokeColor: "#333333" })

      });

map.addLayer(wfs1);
1

I managed to fix this after some sleep and coffee. Changes below:

  • Changed the strategy to BBOX - I don't think this was preventing the map rendering but I think this setting is preferable as it prevents the whole data set loading.
  • Changed the version from 1.0.0 to 1.1.0 (version 1.0.0 does not automatically reproject different SRS)
  • Changed srsName to the same as the base map.

Here's the new code:

 wfs1 = new OpenLayers.Layer.Vector(
        "CamEO Boundary", {
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol : new OpenLayers.Protocol.WFS({
        version : "1.1.0",
        url : "http://centralgeo.co.uk/geoserver/wfs", 
        featurePrefix : "riversdata",
        featureType : "cameo",
        featureNS : "http://centralgeo.co.uk/riversdata",
        srsName: "EPSG:900913", //must be same as base map
        geometryName : "geom"
        }),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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