点击区域高亮
js
import { Fill, Style, Stroke, Text } from 'ol/style.js'
// text: 显示文字
// feature: 要设置的feature
clickFeatureStyle (text = '', feature, fColor = 'rgba(255,216,0)', sColor = '#B9100A') {
feature.setStyle(
new Style({
stroke: new Stroke({
color: sColor,
width: 1
}),
fill: new Fill({
color: fColor
}),
text: new Text({
text: text.toString(),
overflow: true,
textBaseLine: 'middle',
// scale: 1.8,
font: 'bold 90% serif',
zIndex: 2,
fill: new Fill({
color: '#000000'
})
})
})
)
},