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);
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 13, 2015 at 16:58

1 Answer 1

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"
 }),
answered Jan 14, 2015 at 10:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.