@@ -839,7 +839,10 @@ export class WebMap extends Observable {
839839 layerType : 'VECTOR_TILE'
840840 } ) ;
841841 }
842- layerInfo . visibleScale && this . setVisibleScales ( layer , layerInfo . visibleScale ) ;
842+ // 后续逻辑非需要visibleScales 否则修改很复杂
843+ layerInfo . visibleScales = layer . getSource ( ) . getTileGrid ( ) . getResolutions ( ) . map ( ( res ) => {
844+ return Util . resolutionToScale ( res , 96 , layerInfo . coordUnit || 'm' ) ;
845+ } ) ;
843846 //否则没有ID,对不上号
844847 layerInfo . layer = layer ;
845848 layerInfo . layerID = layerID ;
@@ -5178,17 +5181,17 @@ export class WebMap extends Observable {
51785181 createVisibleResolution ( visibleScales , indexbounds , bounds , coordUnit ) {
51795182 let visibleResolution = [ ] ;
51805183 // 1 设置了地图visibleScales的情况
5181- if ( visibleScales && visibleScales . length > 0 ) {
5182- visibleResolution = visibleScales . map ( ( scale ) => {
5183- let value = 1 / scale ;
5184- let res = this . getResFromScale ( value , coordUnit ) ;
5185- return res ;
5186- } ) ;
5187- } else {
5184+ // if (visibleScales && visibleScales.length > 0) {
5185+ // visibleResolution = visibleScales.map((scale) => {
5186+ // let value = 1 / scale;
5187+ // let res = this.getResFromScale(value, coordUnit);
5188+ // return res;
5189+ // });
5190+ // } else {
51885191 // 2 地图的bounds
51895192 let envelope = this . getEnvelope ( indexbounds , bounds ) ;
51905193 visibleResolution = this . getStyleResolutions ( envelope ) ;
5191- }
5194+ // }
51925195 return visibleResolution ;
51935196 }
51945197
@@ -5229,7 +5232,7 @@ export class WebMap extends Observable {
52295232 ) ;
52305233 const envelope = this . getEnvelope ( indexbounds , layerInfo . bounds ) ;
52315234 const styleResolutions = this . getStyleResolutions ( envelope ) ;
5232- // const origin = [envelope.left, envelope.top];
5235+ const origin = [ envelope . left , envelope . top ] ;
52335236 let baseUrl = layerInfo . url ;
52345237 let paramUrl = baseUrl . split ( '?' ) [ 1 ] ;
52355238 if ( layerInfo . dataSource . type === 'ARCGIS_VECTORTILE' ) {
@@ -5273,6 +5276,11 @@ export class WebMap extends Observable {
52735276 style : styles ,
52745277 withCredentials,
52755278 projection : layerInfo . projection ,
5279+ tileGrid : new TileGrid ( {
5280+ resolutions : styleResolutions ,
5281+ origin,
5282+ tileSize : 512
5283+ } ) ,
52765284 format : new MVT ( {
52775285 featureClass : olRenderFeature
52785286 } ) ,
0 commit comments