@@ -2093,14 +2093,8 @@ export class WebMap extends Observable {
2093
2093
this . map . addLayer ( layer ) ;
2094
2094
}
2095
2095
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 ) ;
2104
2098
if ( autoUpdateTime && ! layerInfo . autoUpdateInterval ) {
2105
2099
//自动更新数据
2106
2100
let dataSource = layerInfo . dataSource ;
@@ -2386,9 +2380,26 @@ export class WebMap extends Observable {
2386
2380
this . map . addLayer ( layer ) ;
2387
2381
layer . setVisible ( layerInfo . visible ) ;
2388
2382
layer . setZIndex ( 1000 ) ;
2383
+ const { visibleScale} = layerInfo ;
2384
+ visibleScale && this . setVisibleScales ( layer , visibleScale ) ;
2389
2385
return layer ;
2390
2386
}
2391
2387
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
+
2392
2403
/**
2393
2404
* @private
2394
2405
* @function ol.supermap.WebMap.prototype.getLabelStyle
0 commit comments