最近做图形的绘制和编辑时使用了ol-ext库,虽然成功的能编辑图形,但这个选择的红色线框想修改一下颜色。
直接贴代码:
在这里插入代码片
this._modifyDraw = new Transform({
enableRotatedTransform: false,
addCondition: shiftKeyOnly,
layers: [this.vectorLayer],
hitTolerance: 2,
translateFeature: true,
scale: true,
rotate: false,
keepAspectRatio: false,
keepRectangle: false,
translate: true,
stretch: false,
pointRadius: function (f) {
const radius = f.get('radius') || 10
return [radius, radius]
}
})
this._modifyDraw.overlayLayer_.setStyle(
new Style({
image: new RegularShape({
fill: new Fill({
color: 'rgba(21,129,255,0.1)'
}),
stroke: new Stroke({
color: '#1581FF',
width: 1
}),
radius: 8,
points: 4,
angle: Math.PI / 4
}),
fill: new Fill({
color: 'rgba(21,129,255,0)'
}),
stroke: new Stroke({
color: '#1581FF',
width: 1,
lineDash: [10, 10]
})
})
)
这样设置后样式就变了,如图: