@@ -10,6 +10,13 @@ import { FetchRequest } from '../util/FetchRequest';
10
10
import { SourceListModelV2 } from './utils/SourceListModelV2' ;
11
11
import { isSameRasterLayer , mergeFeatures } from './utils/util' ;
12
12
13
+ const INTERNET_MAP_BOUNDS = {
14
+ TIANDITU : [ - 180 , - 90 , 180 , 90 ] ,
15
+ OSM : [ - 180 , - 90 , 180 , 90 ] ,
16
+ GOOGLE_CN : [ - 180 , - 90 , 180 , 90 ] ,
17
+ BING : [ - 180 , - 90 , 180 , 90 ]
18
+ }
19
+
13
20
export function createWebMapV2Extending ( SuperClass , { MapManager, mapRepo } ) {
14
21
return class WebMapV2 extends SuperClass {
15
22
constructor (
@@ -592,13 +599,15 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
592
599
const isLabel = Boolean ( labelLayerVisible ) ;
593
600
const labelUrl = tiandituUrls . labelUrl ;
594
601
const tiandituUrl = tiandituUrls . tiandituUrl ;
595
- this . _addBaselayer ( { url : tiandituUrl , layerID : name , visibility : visible } ) ;
602
+ const bounds = INTERNET_MAP_BOUNDS [ 'TIANDITU' ] ;
603
+ this . _addBaselayer ( { url : tiandituUrl , layerID : name , visibility : visible , bounds } ) ;
596
604
isLabel &&
597
605
this . _addBaselayer ( {
598
606
url : labelUrl ,
599
607
layerID : this . _getTdtLabelLayerName ( name ) ,
600
608
parentLayerId : name ,
601
- visibility : visible
609
+ visibility : visible ,
610
+ bounds
602
611
} ) ;
603
612
addedCallback && addedCallback ( ) ;
604
613
}
@@ -651,7 +660,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
651
660
return imageUrl ;
652
661
} ) ;
653
662
654
- this . _addBaselayer ( { url : urls , layerID : layerName , visibility : layerInfo . visible } ) ;
663
+ this . _addBaselayer ( { url : urls , layerID : layerName , visibility : layerInfo . visible , bounds : INTERNET_MAP_BOUNDS [ 'BING' ] } ) ;
655
664
addedCallback && addedCallback ( ) ;
656
665
}
657
666
@@ -690,23 +699,53 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
690
699
urlArr = [ url ] ;
691
700
}
692
701
const layerId = layerInfo . layerID || layerInfo . name ;
693
- this . _addBaselayer ( { url : urlArr , layerID : layerId , visibility : layerInfo . visible } ) ;
702
+ this . _addBaselayer ( { url : urlArr , layerID : layerId , visibility : layerInfo . visible , bounds : INTERNET_MAP_BOUNDS [ layerInfo . layerType ] || [ - 180 , - 90 , 180 , 90 ] } ) ;
694
703
addedCallback && addedCallback ( ) ;
695
704
}
696
705
697
706
_createDynamicTiledLayer ( layerInfo , addedCallback ) {
698
707
const url = layerInfo . url ;
699
708
const layerId = layerInfo . layerID || layerInfo . name ;
700
709
const { minzoom, maxzoom } = layerInfo ;
701
- this . _addBaselayer ( {
702
- url : [ url ] ,
703
- layerID : layerId ,
704
- visibility : layerInfo . visible ,
705
- minzoom,
706
- maxzoom,
707
- isIserver : true
710
+ this . getBounds ( `${ url } .json` , {
711
+ withoutFormatSuffix : true ,
712
+ withCredentials : this . webMapService . handleWithCredentials ( '' , url , false )
713
+ } ) . then ( ( res ) => {
714
+ let bounds = null ;
715
+ if ( res && res . bounds ) {
716
+ bounds = [
717
+ res . bounds . left ,
718
+ res . bounds . bottom ,
719
+ res . bounds . right ,
720
+ res . bounds . top
721
+ ] ;
722
+ const epsgCode = res . prjCoordSys . epsgCode ;
723
+ if ( epsgCode !== 4326 ) {
724
+ const [ left , bottom ] = this . _unproject (
725
+ [ res . bounds . left , res . bounds . bottom ]
726
+ ) ;
727
+ const [ right , top ] = this . _unproject (
728
+ [ res . bounds . right , res . bounds . top ]
729
+ ) ;
730
+ bounds = [
731
+ left ,
732
+ bottom ,
733
+ right ,
734
+ top
735
+ ] ;
736
+ }
737
+ }
738
+ this . _addBaselayer ( {
739
+ url : [ url ] ,
740
+ layerID : layerId ,
741
+ visibility : layerInfo . visible ,
742
+ minzoom,
743
+ maxzoom,
744
+ isIserver : true ,
745
+ bounds
746
+ } ) ;
747
+ addedCallback && addedCallback ( ) ;
708
748
} ) ;
709
- addedCallback && addedCallback ( ) ;
710
749
}
711
750
712
751
_createWMSLayer ( layerInfo , addedCallback ) {
@@ -717,7 +756,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
717
756
const layerId = layerInfo . layerID || layerInfo . name ;
718
757
if ( result ) {
719
758
const wmsUrl = this . _getWMSUrl ( layerInfo , result . version ) ;
720
- this . _addBaselayer ( { url : [ wmsUrl ] , layerID : layerId , visibility : layerInfo . visible } ) ;
759
+ this . _addBaselayer ( { url : [ wmsUrl ] , layerID : layerId , visibility : layerInfo . visible , bounds : result . bounds } ) ;
721
760
addedCallback && addedCallback ( ) ;
722
761
}
723
762
} ,
@@ -1244,9 +1283,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
1244
1283
this . map . getSource ( layerInfo . layerID ) && ! addSource
1245
1284
? layerInfo . layerID
1246
1285
: {
1247
- type : 'geojson' ,
1248
- data : { type : 'FeatureCollection' , features : features }
1249
- } ,
1286
+ type : 'geojson' ,
1287
+ data : { type : 'FeatureCollection' , features : features }
1288
+ } ,
1250
1289
paint : {
1251
1290
'text-color' : labelStyle . fill ,
1252
1291
'text-halo-color' : textHaloColor ,
0 commit comments