美文网首页
openlayers在地图上绘制区域面

openlayers在地图上绘制区域面

作者: Henry01 | 来源:发表于2022-04-14 09:39 被阅读0次

// vue中使用场景

<el-button type="primary" plain size="small" @click="polygonFn">开启绘制</el-button>
<el-button type="info" plain size="small" @click="stopFn">关闭绘制</el-button>

var map = {}
var draw // 创建绘制

polygonFn () {
      var _this = this
      if (draw != undefined && draw != null) {
        map.removeInteraction(draw)
      }
      draw = new ol.interaction.Draw({
        source: source,
        type: 'Polygon',
        style: new ol.style.Style({
          image: new ol.style.Circle({
            radius: 5,
            fill: new ol.style.Fill({
              color: '#03a9f4'
            })
          }),
          stroke: new ol.style.Stroke({
            color: '#03a9f4',
            width: 2
          }),
          fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.7)'
          })
        })
      })
      map.addInteraction(draw)
    },

stopFn () {
      if (draw != undefined && draw != null) {
        map.removeInteraction(draw)
      }
    },

相关文章

网友评论

      本文标题:openlayers在地图上绘制区域面

      本文链接:https://www.haomeiwen.com/subject/fjwasrtx.html