简体   繁体   中英

Using wfs-t in OpenLayers 3?

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 ?

This is now up to the application code to handle. The Boundless SDK has some code for this. See: http://boundlessgeo.com/2014/06/openlayers-editing-wfs-t/ and also the code in this repository: https://github.com/boundlessgeo/suite/blob/master/sdk/src/main/resources/client/ol3-common/app/TransactionHandler.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM