olcesium 在2d添加Draw交互画出的面,没有边框线

    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)

olcesium 在2d添加Draw交互画出的面,没有边框线_第1张图片

 需要在添加图层后设置 vectorLayer.set('altitudeMode', 'clampToGround');

也就是这样,3D就可以出现边框线

this.OlMap.addLayer(vectorLayer)

vectorLayer.set('altitudeMode', 'clampToGround');

this.OlMap.addInteraction(draw)

你可能感兴趣的:(javascript,html,html5)