| | |
| | | |
| | | <el-form-item> |
| | | <el-link |
| | | @click="setMapAddDraw()" |
| | | @click="drawRegularPolygon()" |
| | | :underline="false" |
| | | ><i class="el-icon-edit-outline"></i>绘制</el-link> |
| | | </el-form-item> |
| | |
| | | :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 |
| | |
| | | > |
| | | <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%; "> |
| | |
| | | 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" |
| | |
| | | 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, |
| | |
| | | } |
| | | 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() |
| | | |