2

I've updated geoserver with SQL Store and published a table of geometries. When using WMS I get the LineStrings as img so I can't edit them. I've read that WFS bring the data as vector (features) but I wasn't able to find example how to do it (When I preview layer in OpenLayers it comes as WMS only)

How can I do it ?

Alophind
  • 2,707
  • 5
  • 40
  • 75

1 Answers1

2

The server you are obtaining data from must have WFS enabled, otherwise it will not deliver data to you as WFS. Check that by issuing a GetCapabilities request or (if you are the Administrator) go into the admin panel and look there).

Assuming the your server can deliver WFS for that layer, you need to specify your layer in Openlayers as a Vector layer with a WFS protocol something like the following:

var wfsProtocol= new OpenLayers.Protocol.WFS({
    version: "1.1.0",
    url:  "http://localhost/geoserver/wfs",
    featureType: "myVectors",
    srsName: "EPSG:900913",
    featureNS: "www.myURL.ofMyData",
    featurePrefix: "MyWorkspace",
    geometryName: "geom"
    })
var myVectorLayer= new OpenLayers.Layer.Vector('vectorLayer', {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: wfsProtocol
    });

You also must avoid the cross-domain problem and if you do have that, either move your web page to the geoserver www folder or use a proxy.

EDIT: There are a lot of questions that relate directly or indirectly to the cross-domain problem on this forum, e.g. here and here

MappaGnosis
  • 33,857
  • 2
  • 66
  • 129