Openlayers,更新样式后功能消失



我在飞行中改变特征颜色,我在vuemounted末尾使用这个函数

existingFeatures.value.forEach(feature => {
const color = "red"
feature.setStyle(new Style({
stroke: new Stroke({color: color}),
fill: new Fill({color: color})
}));
})

由于某些原因,功能在更新后会消失

答案:setStyle()将覆盖所有样式,所以我需要设置描边和半径

style.getImage().getFill().setColor(color);
style.getImage().getStroke().setColor(color);
style.getImage().setRadius(5)

最新更新