добавить атрибут в векторный слой в открытых слоях с помощью сервиса wfst - PullRequest
0 голосов
/ 29 апреля 2019

У меня есть приложение, в котором я использую сервис wfst для импорта и изменения точечного слоя из postgres, используя геосервер. Я хочу добавить атрибуты к существующему слою и создать стили точек на основе этих полей. Ниже приведен код, который я использую дляимпорт слоев и включение меток.

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 interactionSelectPointerMove = new ol.interaction.Select({
    condition: ol.events.condition.pointerMove
});
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;

    }

});
...