我在Geoserver中发布了一个WFS点图层,该图层在开放层上显示,我可以使用以下代码以标签形式访问属性。我想编辑一个特定的属性。我还要基于该属性值更改编辑点的样式。
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;
}
});