i have a WFS point layer published in Geoserver that i am displaying on open layers I can access attributes in the form of labels using the following code. I want to edit a particular attribute.Also i want to change the style of the edited point based on that attribute value.

var sourceWFS = new ol.source.Vector({
    loader: function (extent) {
        $.ajax('http://localhost:8080/geoserver/workspace/ows?', {
            type: 'GET',
            data: {
                service: 'WFS',
                version: '1.1.0',
                request: 'GetFeature',
                typename: 'layer',
                srsname: 'EPSG:3857',
                geometryField:'geometry',
                bbox: extent.join(',') + ',EPSG:3857'
            }

        }).done(function (response) {
            sourceWFS.addFeatures(formatWFS.readFeatures(response));
        });
    },
    strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ()),
    strategy: ol.loadingstrategy.bbox,
    projection: 'EPSG:3857',
});
var selectStyle = new ol.style.Style({ 

    stroke: new ol.style.Stroke({
        color: 'rgba(0,0,0,1.0)',
        width: 1
    }),
    fill: new ol.style.Fill({
        color: 'rgba(0,0,0,0.5)'
    }),
    text: new ol.style.Text({
        text:"abcd",
         scale: 2,
         color: 'red',

    })

});

var interactionSelect = new ol.interaction.Select({

style: function(feature) {
    console.log(feature.getProperties());

        selectStyle.getText().setText(feature.get('Number'));
        return selectStyle;

    }

});

0 Answers