@@ -424,7 +424,7 @@ export class WebMap extends Observable {
424
424
baseLayerInfo . visibleScales . forEach ( scale => {
425
425
let value = 1 / scale ;
426
426
res = this . getResFromScale ( value , coordUnit ) ;
427
- scale = `1:${ value . toLocaleString ( ) } ` ;
427
+ scale = `1:${ value } ` ;
428
428
//多此一举转换,因为toLocalString会自动保留小数点后三位,and当第二位小数是0就会保存小数点后两位。所有为了统一。
429
429
resolutions [ this . formatScale ( scale ) ] = res ;
430
430
resolutionArray . push ( res ) ;
@@ -433,7 +433,7 @@ export class WebMap extends Observable {
433
433
} else if ( baseLayerInfo . layerType === 'WMTS' ) {
434
434
baseLayerInfo . scales . forEach ( scale => {
435
435
res = this . getResFromScale ( scale , coordUnit , 90.7 ) ;
436
- scale = `1:${ scale . toLocaleString ( ) } ` ;
436
+ scale = `1:${ scale } ` ;
437
437
//多此一举转换,因为toLocalString会自动保留小数点后三位,and当第二位小数是0就会保存小数点后两位。所有为了统一。
438
438
resolutions [ this . formatScale ( scale ) ] = res ;
439
439
resolutionArray . push ( res ) ;
@@ -480,7 +480,7 @@ export class WebMap extends Observable {
480
480
getScaleFromRes ( resolution , coordUnit = "DEGREE" , dpi = 96 ) {
481
481
let scale , mpu = metersPerUnit [ coordUnit . toUpperCase ( ) ] ;
482
482
scale = resolution * dpi * mpu / .0254 ;
483
- return '1:' + scale . toLocaleString ( ) ;
483
+ return '1:' + scale ;
484
484
}
485
485
/**
486
486
* @private
@@ -703,11 +703,20 @@ export class WebMap extends Observable {
703
703
const scales = this . scales . map ( ( scale ) => {
704
704
return 1 / scale . split ( ':' ) [ 1 ] ;
705
705
} ) ;
706
- visibleScales = baseLayer . visibleScales || scales ;
706
+ if ( Array . isArray ( baseLayer . visibleScales ) && baseLayer . visibleScales . length && baseLayer . visibleScales ) {
707
+ visibleScales = baseLayer . visibleScales ;
708
+ } else {
709
+ visibleScales = scales ;
710
+ }
707
711
minScale = 1 / mapInfo . minScale . split ( ':' ) [ 1 ] ;
708
712
maxScale = 1 / mapInfo . maxScale . split ( ':' ) [ 1 ] ;
709
713
}
710
-
714
+ if ( minScale > maxScale ) {
715
+ let temp = null ;
716
+ temp = minScale ;
717
+ minScale = maxScale ;
718
+ maxScale = temp ;
719
+ }
711
720
const minVisibleScale = this . findNearest ( visibleScales , minScale ) ;
712
721
const maxVisibleScale = this . findNearest ( visibleScales , maxScale ) ;
713
722
const minZoom = visibleScales . indexOf ( minVisibleScale ) ;
@@ -829,7 +838,7 @@ export class WebMap extends Observable {
829
838
// if(options.baseLayer.visibleScales && options.baseLayer.visibleScales.length > 0){
830
839
// maxZoom = options.baseLayer.visibleScales.length;
831
840
// }
832
- this . map . setView ( new View ( { zoom, center, projection, maxZoom } ) ) ;
841
+ this . map . setView ( new View ( { zoom, center, projection, maxZoom, maxResolution } ) ) ;
833
842
let viewOptions = { } ;
834
843
835
844
if ( baseLayer . scales && baseLayer . scales . length > 0 && baseLayer . layerType === "WMTS" ||
0 commit comments