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 ?

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

  • This is proxy problem , It works on my iis. How can I define proxy in JSFIddle ? – Alophind Jul 23 '13 at 19:04
  • I've added a couple of links to my answer. – MappaGnosis Jul 24 '13 at 7:10
  • Thx , I've wanted to know how I can add proxy to JSFiddle so examples will work. – Alophind Jul 24 '13 at 8:39

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.