0

I am trying to update the attributes of existing features in a WFS. When the users clicks on a feature on the map, a popup appears and there is a clickable link in the popup that converts the attribute text values to input forms. My idea is that the user could modify the value in the form and then write that back to the database. However when I change values in the input form, the data does not change after executing the write transaction, though the form shows the edit, until I refresh the application. The variable feat is an instance of ol feature that I capture when the user clicks on the map. Here is my code, what am i missing?

function submit_edit(){
            console.log(feat);
            var priority_val = popup_table.rows[0].querySelector('input').value;
            var notes_val = popup_table.rows[1].querySelector('input').value;

            var editWFS = new ol.format.WFS();
            var editGML = new ol.format.GML({
                featureNS: 'http://geoserver.sf.net/sde',
                featureType: 'parcels_slim',
                srsName: 'EPSG:3857',
                });

            var transactWFS = function(p,f) {
                switch(p) {
                case 'insert':
                    node = editWFS.writeTransaction([f],null,null,editGML);
                    break;
                case 'update':
                    node = editWFS.writeTransaction(null,[f],null,editGML);
                    break;
                case 'delete':
                    node = editWFS.writeTransaction(null,null,[f],editGML);
                    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();
            }
            feat.set('priority_final', priority_val);
            feat.set('notes', notes_val);
            transactWFS('update', feat);

            alert('edit submitted');

        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.