管道基础大数据平台系统开发-【前端】-新系統界面
王旭
2023-05-10 7a0c7de021aebbef3ec137f2f94ff73ab41014d7
src/views/exportMap/index.vue
@@ -36,7 +36,7 @@
        <el-form-item>
          <el-link
            @click="setMapAddDraw()"
            @click="drawRegularPolygon()"
            :underline="false"
          ><i class="el-icon-edit-outline"></i>绘制</el-link>
        </el-form-item>
@@ -75,13 +75,13 @@
            :underline="false"
          >矢量</el-link>
        </el-form-item>
        <el-form-item label="旋转角度">
        <!-- <el-form-item label="旋转角度">
          <el-input
            v-model="formInline.role"
            placeholder="请输入内容"
            @change="setMapRole"
          ></el-input>
        </el-form-item>
        </el-form-item> -->
      </el-form>
    </div>
    <div
@@ -131,6 +131,12 @@
      >
        <el-form-item label="出图名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="旋转角度">
          <el-input
            v-model="formInline.role"
            placeholder="请输入旋转角度(0-360)"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <div style="padding: 1%;  ">
@@ -279,6 +285,8 @@
import TileLayer from "ol/layer/Tile"
import { transform } from "ol/proj"
import Draw, { createRegularPolygon, createBox } from "ol/interaction/Draw.js"
import { OSM, Vector as VectorSource } from "ol/source"
import { Vector as VectorLayer } from "ol/layer"
import LayerVector from "ol/layer/Vector"
@@ -500,7 +508,7 @@
        resolution: "20米",
        date: this.getYMD(),
        layers: res.toString(),
        rotation: 0,
        rotation: this.form.role,
        xmin: this.layerExtent.xmin,
        ymin: this.layerExtent.ymin,
        xmax: this.layerExtent.xmax,
@@ -548,7 +556,53 @@
      }
      this.layerExtent = null
    },
    stopDraw() {
      // if (this.draw !== null) {
      //   this.map.removeInteraction(this.draw)
      // }
      if (this.draw != null) {
        mapView.removeLayer(this.vector)
      }
      this.layerExtent = null
    },
    drawRegularPolygon() {
      this.stopDraw();
      this.source = new VectorSource({ wrapX: false })
      this.vector = new VectorLayer({
        source: this.source,
      })
      mapView.addLayer(this.vector)
      let type = 'Circle'
      let geometryFunction2 = createRegularPolygon(4)
      this.draw = new Draw({
        source: this.source,
        type: type,
        geometryFunction: geometryFunction2
      })
      mapView.addInteraction(this.draw)
      this.draw.on("drawend", e => {
        let feature = e.feature
        let geom = feature.getGeometry()
        var extent = geom.getExtent()
        var a1 = transform([extent[0], extent[1]], "EPSG:3857", "EPSG:4326")
        var a2 = transform([extent[2], extent[3]], "EPSG:3857", "EPSG:4326")
        this.layerExtent = {
          xmin: a1[0],
          ymin: a1[1],
          xmax: a2[0],
          ymax: a2[1],
        }
        mapView.removeInteraction(this.draw)
      })
    },
    //绘制图形
    setMapAddDraw() {
      this.setMapRemoveDraw()