2

I'm using OpenLayers-3.6.0 in a web application. I have wfs layer as follow:

var url="http://localhost:8080/geoserver/wfs?&" + 
      "service=wfs&version=1.1.0&request=GetFeature&typeNames=usa:states";
var format = new ol.format.WFS({});
var source = new ol.source.Vector({
    url: 'proxy.cgi?url='+ encodeURIComponent(url),
    format: format
});
layer wfs = new ol.layer.Vector({
    title: 'states',
    source: source
});

I edit this Point layer as follow:

draw = new ol.interaction.Draw({
    source: source,
    type: 'Point'
});

Now I want to save this layer in server side. In OpenLayers-2 we defined a saveStrategy and then call save method of it. It is shown as follows:

var saveStrategy = new OpenLayers.Strategy.Save();

/*
* change layer's features
*/

saveStratefy.save();

How can I do it in OpenLayers-3.6.0?

6

Have a look at my blog for a bit on WFS-T. This uses the OL 3.5 library.

https://medium.com/@goldrydigital/wfs-t-with-openlayers-3-16-6fb6a820ac58

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1

I don't need it everyday so I didn't reuse it recently but you can look at https://github.com/boundlessgeo/suite/tree/master/sdk/src/main/resources/client

It's the place where the code for OpenLayers 3 templates in OpenGeo Suite is. One of these templates is for using WFS-T. You have to look at ol3edit and also ol3-common. You will need to analyse JavaScript code as they (Boundless, the company behind) made a custom component for this purpose.

  • The link is now 404. Is it possible someone with the knowledge of where it pointed to could update it? – Félix Gagnon-Grenier Oct 24 '18 at 21:11

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.