所以我试着设置一个这样的特征颜色,
addInteraction() {
this.style = new Style({
fill: new Fill({
color: this.fillColour,
}),
stroke: new Stroke({
color: this.lineColour,
width: 2
}),
image: new CircleStyle({
radius: 7,
fill: new Fill({
color: this.fillColour
}),
stroke: new Stroke({
color: this.lineColour
})
})
})
this.draw = new Draw({
source: this.vectorSource,
style: [this.style],
type: this.selectedShape,
})
this.coreMap.map.addInteraction(this.draw)
this.snap = new Snap({ source: this.vectorSource })
this.coreMap.map.addInteraction(this.snap);
this.coreMap.map.addInteraction(this.modifyLayer);
}
如果我将样式应用到vectorLayer,它将保持不变,但我希望特性保持颜色而不是图层,因为我希望在一个图层上具有多种颜色的多个特性,我尝试了几种不同的方法,例如使用简单的设置方法在newDraw对象外部设置颜色,或者在draw对象中使用样式函数设置样式,但运气不佳。