Skip to content

Commit d450b37

Browse files
committed
[fix] ol webmap 修复wms服务为底图时,默认情况下不显示全图
review by zhaoq
1 parent 3c05f97 commit d450b37

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,11 @@ export class WebMap extends Observable {
723723

724724
// 计算当前最大分辨率
725725
let baseLayer = options.baseLayer;
726-
let maxResolution, minResolution;
726+
let maxResolution;
727727
if ((baseLayer.visibleScales && baseLayer.visibleScales.length > 0) || (baseLayer.scales && baseLayer.scales.length > 0)) {
728728
//底图有固定比例尺,就直接获取。不用view计算
729729
this.getScales(baseLayer);
730-
} else if (options.baseLayer && ['TILE', 'VECTOR_TILE'].indexOf(options.baseLayer.layerType) > -1 && extent && extent.length === 4) {
730+
} else if (options.baseLayer && extent && extent.length === 4) {
731731
let width = extent[2] - extent[0];
732732
let height = extent[3] - extent[1];
733733
let maxResolution1 = width / 512;
@@ -739,21 +739,16 @@ export class WebMap extends Observable {
739739
// maxZoom = options.baseLayer.visibleScales.length;
740740
// }
741741
let viewOptions = {};
742-
if (baseLayer.layerType === "WMTS") {
743-
if (baseLayer.scales && baseLayer.scales.length > 0) {
744-
//因为新版extent超出,不可见。所以将extent去除
745-
viewOptions = {zoom, center, projection, resolutions: this.resolutionArray, maxZoom};
746-
} else {
747-
viewOptions = {zoom, center, projection, maxZoom};
748-
this.getScales(baseLayer);
749-
}
742+
743+
if (baseLayer.scales && baseLayer.scales.length > 0 && baseLayer.layerType === "WMTS" ||
744+
this.resolutionArray && this.resolutionArray.length > 0) {
745+
viewOptions = { zoom, center, projection, resolutions: this.resolutionArray, maxZoom };
746+
} else if (baseLayer.layerType === "WMTS") {
747+
viewOptions = { zoom, center, projection, maxZoom };
748+
this.getScales(baseLayer);
750749
} else {
751-
if (this.resolutionArray && this.resolutionArray.length > 0) {
752-
viewOptions = {zoom, center, projection, resolutions: this.resolutionArray, maxZoom};
753-
} else {
754-
viewOptions = {zoom, center, projection, maxResolution, minResolution, maxZoom};
755-
this.getScales(baseLayer);
756-
}
750+
viewOptions = { zoom, center, projection, maxResolution, maxZoom };
751+
this.getScales(baseLayer);
757752
}
758753
if (['4', '5'].indexOf(Util.getOlVersion()) < 0) { // 兼容 ol 4,5,6
759754
viewOptions.multiWorld = true;
@@ -762,7 +757,7 @@ export class WebMap extends Observable {
762757
viewOptions.constrainResolution = true; //设置此参数,是因为需要显示整数级别。为了可视比例尺中包含当前比例尺
763758
}
764759
this.map.setView(new View(viewOptions));
765-
760+
766761
if (options.visibleExtent) {
767762
const view = this.map.getView();
768763
const resolution = view.getResolutionForExtent(options.visibleExtent, this.map.getSize());

0 commit comments

Comments
 (0)