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);
break;
case 'update':
node = formatWFS.writeTransaction(null,[f],null,formatGML);
break;
case 'delete':
node = formatWFS.writeTransaction(null,null,[f],formatGML);
break;
}
s = new XMLSerializer();
str = s.serializeToString(node);
$.ajax('http://localhost:8080/geoserver/wfs',{
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: str
}).done();
}
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