Skip to content

Commit 91d0812

Browse files
committed
【bug】1) webmap,restjsr图层可见范围不生效
(reviewed by qiulin)
1 parent 11e0411 commit 91d0812

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ export class WebMap extends Observable {
683683
layerType: 'VECTOR_TILE'
684684
});
685685
}
686-
686+
layerInfo.visibleScale && this.setVisibleScales(layer, layerInfo.visibleScale);
687687
//否则没有ID,对不上号
688688
layerInfo.layer = layer;
689689
layerInfo.layerID = layerID;
@@ -738,30 +738,35 @@ export class WebMap extends Observable {
738738
// if(options.baseLayer.visibleScales && options.baseLayer.visibleScales.length > 0){
739739
// maxZoom = options.baseLayer.visibleScales.length;
740740
// }
741-
let viewOptions;
741+
let viewOptions = {};
742+
if (['4', '5'].indexOf(Util.getOlVersion()) < 0) { // 兼容 ol 4,5,6
743+
viewOptions.multiWorld = true;
744+
viewOptions.showFullExtent = true;
745+
viewOptions.enableRotation = false;
746+
viewOptions.constrainResolution = true; //设置此参数,是因为需要显示整数级别。为了可视比例尺中包含当前比例尺
747+
}
742748
if (baseLayer.layerType === "WMTS") {
743749
if (baseLayer.scales && baseLayer.scales.length > 0) {
744750
//因为新版extent超出,不可见。所以将extent去除
745751
viewOptions = {zoom, center, projection, resolutions: this.resolutionArray, maxZoom};
752+
this.map.setView(new View(viewOptions));
746753
} else {
747754
viewOptions = {zoom, center, projection, maxZoom};
755+
this.map.setView(new View(viewOptions));
748756
this.getScales(baseLayer);
749757
}
750758
} else {
751759
if (this.resolutionArray && this.resolutionArray.length > 0) {
752760
viewOptions = {zoom, center, projection, resolutions: this.resolutionArray, maxZoom};
761+
this.map.setView(new View(viewOptions));
753762
} else {
754763
viewOptions = {zoom, center, projection, maxResolution, minResolution, maxZoom};
764+
this.map.setView(new View(viewOptions));
755765
this.getScales(baseLayer);
756766
}
757767
}
758-
if (['4', '5'].indexOf(Util.getOlVersion()) < 0) { // 兼容 ol 4,5,6
759-
viewOptions.multiWorld = true;
760-
viewOptions.showFullExtent = true;
761-
viewOptions.enableRotation = false;
762-
viewOptions.constrainResolution = true; //设置此参数,是因为需要显示整数级别。为了可视比例尺中包含当前比例尺
763-
}
764-
this.map.setView(new View(viewOptions));
768+
769+
765770
if (options.visibleExtent) {
766771
const view = this.map.getView();
767772
const resolution = view.getResolutionForExtent(options.visibleExtent, this.map.getSize());
@@ -1301,7 +1306,7 @@ export class WebMap extends Observable {
13011306
// layerInfo.projection = mapInfo.projection;
13021307
// layerInfo.extent = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y];
13031308
// 比例尺 单位
1304-
if(result.code !== 200) {
1309+
if(result && result.code && result.code !== 200) {
13051310
throw result;
13061311
}
13071312
if (result.visibleScales) {

0 commit comments

Comments
 (0)