@@ -10,6 +10,13 @@ import { FetchRequest } from '../util/FetchRequest';
1010import { SourceListModelV2 } from './utils/SourceListModelV2' ;
1111import { isSameRasterLayer , mergeFeatures } from './utils/util' ;
1212
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+
1320export function createWebMapV2Extending ( SuperClass , { MapManager, mapRepo } ) {
1421 return class WebMapV2 extends SuperClass {
1522 constructor (
@@ -592,13 +599,15 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
592599 const isLabel = Boolean ( labelLayerVisible ) ;
593600 const labelUrl = tiandituUrls . labelUrl ;
594601 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 } ) ;
596604 isLabel &&
597605 this . _addBaselayer ( {
598606 url : labelUrl ,
599607 layerID : this . _getTdtLabelLayerName ( name ) ,
600608 parentLayerId : name ,
601- visibility : visible
609+ visibility : visible ,
610+ bounds
602611 } ) ;
603612 addedCallback && addedCallback ( ) ;
604613 }
@@ -651,7 +660,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
651660 return imageUrl ;
652661 } ) ;
653662
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' ] } ) ;
655664 addedCallback && addedCallback ( ) ;
656665 }
657666
@@ -690,23 +699,53 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
690699 urlArr = [ url ] ;
691700 }
692701 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 ] } ) ;
694703 addedCallback && addedCallback ( ) ;
695704 }
696705
697706 _createDynamicTiledLayer ( layerInfo , addedCallback ) {
698707 const url = layerInfo . url ;
699708 const layerId = layerInfo . layerID || layerInfo . name ;
700709 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 ( ) ;
708748 } ) ;
709- addedCallback && addedCallback ( ) ;
710749 }
711750
712751 _createWMSLayer ( layerInfo , addedCallback ) {
@@ -717,7 +756,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
717756 const layerId = layerInfo . layerID || layerInfo . name ;
718757 if ( result ) {
719758 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 } ) ;
721760 addedCallback && addedCallback ( ) ;
722761 }
723762 } ,
@@ -1244,9 +1283,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
12441283 this . map . getSource ( layerInfo . layerID ) && ! addSource
12451284 ? layerInfo . layerID
12461285 : {
1247- type : 'geojson' ,
1248- data : { type : 'FeatureCollection' , features : features }
1249- } ,
1286+ type : 'geojson' ,
1287+ data : { type : 'FeatureCollection' , features : features }
1288+ } ,
12501289 paint : {
12511290 'text-color' : labelStyle . fill ,
12521291 'text-halo-color' : textHaloColor ,
0 commit comments