Skip to content

Commit ba600a7

Browse files
committed
【bug】1) webMap修复可视范围设置,专题图标签没有统一
(reviewed by chengl)
1 parent ce528ba commit ba600a7

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,14 +2093,8 @@ export class WebMap extends Observable {
20932093
this.map.addLayer(layer);
20942094
}
20952095
layer.setZIndex(index);
2096-
let {visibleScale, autoUpdateTime} = layerInfo, minResolution, maxResolution;
2097-
if(visibleScale) {
2098-
maxResolution = this.resolutions[visibleScale.minScale];
2099-
minResolution = this.resolutions[visibleScale.maxScale];
2100-
//比例尺和分别率是反比的关系
2101-
maxResolution > 1 ? layer.setMaxResolution(Math.ceil(maxResolution)) : layer.setMaxResolution(maxResolution * 1.1);
2102-
layer.setMinResolution(minResolution);
2103-
}
2096+
const {visibleScale, autoUpdateTime} = layerInfo;
2097+
visibleScale && this.setVisibleScales(layer, visibleScale);
21042098
if(autoUpdateTime && !layerInfo.autoUpdateInterval) {
21052099
//自动更新数据
21062100
let dataSource = layerInfo.dataSource;
@@ -2386,9 +2380,26 @@ export class WebMap extends Observable {
23862380
this.map.addLayer(layer);
23872381
layer.setVisible(layerInfo.visible);
23882382
layer.setZIndex(1000);
2383+
const {visibleScale} = layerInfo;
2384+
visibleScale && this.setVisibleScales(layer, visibleScale);
23892385
return layer;
23902386
}
23912387

2388+
/**
2389+
* @private
2390+
* @function ol.supermap.WebMap.prototype.setVisibleScales
2391+
* @description 改变图层可视范围
2392+
* @param {object} layer - 图层对象。ol.Layer
2393+
* @param {object} visibleScale - 图层样式参数
2394+
*/
2395+
setVisibleScales(layer, visibleScale) {
2396+
let maxResolution = this.resolutions[visibleScale.minScale],
2397+
minResolution = this.resolutions[visibleScale.maxScale];
2398+
//比例尺和分别率是反比的关系
2399+
maxResolution > 1 ? layer.setMaxResolution(Math.ceil(maxResolution)) : layer.setMaxResolution(maxResolution * 1.1);
2400+
layer.setMinResolution(minResolution);
2401+
}
2402+
23922403
/**
23932404
* @private
23942405
* @function ol.supermap.WebMap.prototype.getLabelStyle

0 commit comments

Comments
 (0)