this.OlMap = new Map('map')
let source = new VectorSource({})
let style = new Style({
fill: new Fill({
color: 'rgba(255, 255,0, .5)',
}),
stroke: new Stroke({
color: 'blue',
width: 2,
}),
image: new CircleStyle({
radius: 7,
fill: new Fill({
color: '#f00',
})
}),
})
let vectorLayer = new VectorLayer({
source,
style,
})
let draw = new Draw({
source,
type: 'Polygon',
})
this.OlMap.addLayer(vectorLayer)
this.OlMap.addInteraction(draw)
需要在添加图层后设置 vectorLayer.set('altitudeMode', 'clampToGround');
也就是这样,3D就可以出现边框线
this.OlMap.addLayer(vectorLayer)
vectorLayer.set('altitudeMode', 'clampToGround');
this.OlMap.addInteraction(draw)