月球大数据地理空间分析展示平台-【前端】-月球2期前端
Surpriseplus
2023-09-04 1355c04087927dfed32827d23609e2b04a8cabea
src/assets/js/Map/olMap.js
@@ -196,7 +196,27 @@
    });
    if (this.map) {
      this.map.addLayer(this.Layer);
      var that = this;
      window.olMap = this.map;
      window.layer = this.Layer
      setTimeout(() => {
        that.getLayersExtent();
      }, 1000)
      // this.Layer.getSource().on('addfeature', function () {
      //   this.map.getView().fit(this.Layer.getSource().getExtent());
      // });
    }
  },
  getLayersExtent() {
    // 缩放至图层范围
    this.map.getView().fit(this.Layer.renderer_.renderedExtent_);
  }
};
export default olMap;