From 7a0c7de021aebbef3ec137f2f94ff73ab41014d7 Mon Sep 17 00:00:00 2001 From: 王旭 <1377869194@qq.com> Date: 星期三, 10 五月 2023 14:44:47 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.20.39:8989/r/LFWEB_NEW --- src/views/exportMap/index.vue | 62 +++++++++++++++++++++++++++++-- 1 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/views/exportMap/index.vue b/src/views/exportMap/index.vue index ed7d7bc..6af9cac 100644 --- a/src/views/exportMap/index.vue +++ b/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() -- Gitblit v1.9.3