【发布时间】:2019-01-09 10:27:55
【问题描述】:
所以我正在尝试像这样设置特征颜色,
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);
}
现在,当我绘制特征时,假设它是一个带有红线和蓝色填充的圆圈,它会在我绘制时显示一个带有红线和蓝色填充的圆圈,但一旦完成绘制,它将默认为openlayers 默认颜色为浅蓝色上的蓝色。
如果我将样式应用于vectorLayer,它将保持不变,但我希望该功能保持颜色而不是图层,因为我希望在一个图层上有多个具有多种颜色的功能,我尝试了几种不同的方法,例如设置使用简单的 set 方法设置 newDraw 对象外部的颜色,或者使用 draw 对象内部的样式函数设置样式,但没有运气。
【问题讨论】:
-
你需要在
drawendol.interaction.Draw事件上设置样式
标签: angular openlayers openlayers-3 openlayers-5