From f4a54f5d378fb194d4132de2668e5d85a255b8ff Mon Sep 17 00:00:00 2001 From: surprise <15810472099@163.com> Date: 星期四, 26 十月 2023 15:07:55 +0800 Subject: [PATCH] 版本更新 --- src/assets/js/Map/olMap.js | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/assets/js/Map/olMap.js b/src/assets/js/Map/olMap.js index 3c8ca6f..e968043 100644 --- a/src/assets/js/Map/olMap.js +++ b/src/assets/js/Map/olMap.js @@ -14,6 +14,7 @@ import { getTopLeft, getWidth } from "ol/extent.js"; import { format } from "ol/coordinate"; import store from "@/store"; +import { nextTick } from "vue"; const olMap = { map: null, Layer: null, @@ -166,7 +167,7 @@ }, deleteLayer() { if (this.map && this.Layer) { - + this.map.removeLayer(this.Layer); this.Layer = null; } @@ -185,7 +186,6 @@ this.map.values_.view.projection_ = projection } - // var projection = getProjection("ESRI:103880"); var projectionExtent = projection.getExtent(); var size = getWidth(projectionExtent) / 256; @@ -215,7 +215,22 @@ }); if (this.map) { this.map.addLayer(this.Layer); - this.map.getView().fit(this.projectionObj.extent); + // + // + + // this.map.getView().fit(this.projectionObj.extent, this.map.getSize()); + if (res.bak) { + var obj = JSON.parse(res.bak); + this.map.getView().setCenter(obj.center) + this.map.getView().setZoom(obj.zoom); + } else { + this.map.getView().fit(this.projectionObj.extent); + // var val = this.projectionObj.extent; + // this.map.getView().setCenter([(val[0] + val[1]) / 2, (val[2] + val[3]) / 2.4]) + // this.map.getView().setZoom(3); + } + + } }, -- Gitblit v1.9.3