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;