So with an app that I've produced by taking this into account, I've managed to create a web map with editing function using a WFS layer from Geoserver.

Problem is that, unlike in the working example, the edits are not being saved properly, so every time the page gets refreshed, it seems that the edits become lost.

Weird thing is that every time I draw a line, in my Postgis database there are new entries being created, but the geometry is not being recorded. The delete button doesn't work as well

The portion that saves it to the WFS layer is:

var formatWFS = new ol.format.WFS();
var formatGML = new ol.format.GML({
featureNS: 'http://geoserver.org/bftchamber',
featureType: 'bft',
srsName: 'EPSG:27700'
var transactWFS = function(p,f) {
switch(p) {
case 'insert':
    node = formatWFS.writeTransaction([f],null,null,formatGML);
case 'update':
    node = formatWFS.writeTransaction(null,[f],null,formatGML);
case 'delete':
    node = formatWFS.writeTransaction(null,null,[f],formatGML);
s = new XMLSerializer();
str = s.serializeToString(node);
    type: 'POST',
    dataType: 'xml',
    processData: false,
    contentType: 'text/xml',
    data: str

Fiddle is here https://jsfiddle.net/Luffydude/ex06jr1e/7/

Also or some reason, my existing drawn line loads correctly in QGIS, but in the app it just loads in the middle of the ocean. In my code I've specified EPSG 27700 but seems that a different SRS is being used


Hi Luffydude as weird as it seems you get the same errors I had on my last project a couple of weeks ago, so this is how I worked it around:

1- the geometry column not being inserted means that you need to specify it in the feature you are sending in WFS-T request, so before you do this


add the following to your code in the drawend function :


2- the second one I think if you check the coordinates you'll find that they are inverted lon/lat or lat/lon, so try to remove the line wher you define the srsName in formatGML, this will let your drawn features be stored with the default SRS you used in declaring your map. if this doesn't work I found a workaround to it I'll post it in case this doesn't work.

  • Hicham to the rescue :D About the 2, I removed every mention of SRS or EPSG 27700 from my code, yet still it doesn't appear where it's supposed to. Also it's not a case of inverted coordinates, I've tried inverting the coordinates in qgis and the location is completely different from the one shown in the map. I suspect it's just projecting my WFS using a random coordinate system – Luffydude Jun 6 '16 at 14:58
  • About the 1, I tried a few locations for your line, but directly above formatWFS.writeTransaction([f],null,null,formatGML); returns app.js:95 Uncaught TypeError: Cannot read property 'getGeometry' of undefined – Luffydude Jun 6 '16 at 14:59
  • could you add this line to your ajax call just after data:str, success: function(data){alert(new XMLSerializer().serializeToString(data));} and post the output this way we can see the actual error – Hicham Zouarhi Jun 6 '16 at 15:26
  • in the console it returns this error: app.js:111 Uncaught SyntaxError: Unexpected token function (111 is the line introduced) – Luffydude Jun 6 '16 at 15:39
  • and does it display any xml code in the alert popup ? – Hicham Zouarhi Jun 6 '16 at 15:41

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.