月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2023-10-26 f4a54f5d378fb194d4132de2668e5d85a255b8ff
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);
      }
    }
  },