@@ -683,7 +683,7 @@ export class WebMap extends Observable {
683
683
layerType : 'VECTOR_TILE'
684
684
} ) ;
685
685
}
686
-
686
+ layerInfo . visibleScale && this . setVisibleScales ( layer , layerInfo . visibleScale ) ;
687
687
//否则没有ID,对不上号
688
688
layerInfo . layer = layer ;
689
689
layerInfo . layerID = layerID ;
@@ -738,30 +738,35 @@ export class WebMap extends Observable {
738
738
// if(options.baseLayer.visibleScales && options.baseLayer.visibleScales.length > 0){
739
739
// maxZoom = options.baseLayer.visibleScales.length;
740
740
// }
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
+ }
742
748
if ( baseLayer . layerType === "WMTS" ) {
743
749
if ( baseLayer . scales && baseLayer . scales . length > 0 ) {
744
750
//因为新版extent超出,不可见。所以将extent去除
745
751
viewOptions = { zoom, center, projection, resolutions : this . resolutionArray , maxZoom} ;
752
+ this . map . setView ( new View ( viewOptions ) ) ;
746
753
} else {
747
754
viewOptions = { zoom, center, projection, maxZoom} ;
755
+ this . map . setView ( new View ( viewOptions ) ) ;
748
756
this . getScales ( baseLayer ) ;
749
757
}
750
758
} else {
751
759
if ( this . resolutionArray && this . resolutionArray . length > 0 ) {
752
760
viewOptions = { zoom, center, projection, resolutions : this . resolutionArray , maxZoom} ;
761
+ this . map . setView ( new View ( viewOptions ) ) ;
753
762
} else {
754
763
viewOptions = { zoom, center, projection, maxResolution, minResolution, maxZoom} ;
764
+ this . map . setView ( new View ( viewOptions ) ) ;
755
765
this . getScales ( baseLayer ) ;
756
766
}
757
767
}
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
+
765
770
if ( options . visibleExtent ) {
766
771
const view = this . map . getView ( ) ;
767
772
const resolution = view . getResolutionForExtent ( options . visibleExtent , this . map . getSize ( ) ) ;
@@ -1301,7 +1306,7 @@ export class WebMap extends Observable {
1301
1306
// layerInfo.projection = mapInfo.projection;
1302
1307
// layerInfo.extent = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y];
1303
1308
// 比例尺 单位
1304
- if ( result . code !== 200 ) {
1309
+ if ( result && result . code && result . code !== 200 ) {
1305
1310
throw result ;
1306
1311
}
1307
1312
if ( result . visibleScales ) {
0 commit comments