@@ -37,6 +37,7 @@ import * as olGeometry from 'ol/geom';
37
37
import Vector from 'ol/source/Vector' ;
38
38
import XYZ from 'ol/source/XYZ' ;
39
39
import WMTS from 'ol/source/WMTS' ;
40
+ import BingMaps from 'ol/source/BingMaps' ;
40
41
import TileWMS from 'ol/source/TileWMS' ;
41
42
import Feature from 'ol/Feature' ;
42
43
import olRenderFeature from 'ol/render/Feature' ;
@@ -86,6 +87,7 @@ const dpiConfig = {
86
87
* @param {boolean } [options.excludePortalProxyUrl] - server 传递过来的 URL 是否带有代理。
87
88
* @param {Object } [options.serviceProxy] - SuperMap iPortal 内置代理信息,仅矢量瓦片图层上图才会使用。
88
89
* @param {string } [options.tiandituKey] - 天地图的 key。
90
+ * @param {string } [options.bingMapsKey] - 必应地图的 key。
89
91
* @param {string } [options.googleMapsAPIKey] - 谷歌底图需要的 key。
90
92
* @param {string } [options.proxy] - 代理地址,当域名不一致,请求会加上代理。避免跨域。
91
93
* @param {string } [options.tileFormat] - 地图瓦片出图格式,png/webp。
@@ -118,6 +120,7 @@ export class WebMap extends Observable {
118
120
this . excludePortalProxyUrl = options . excludePortalProxyUrl || false ;
119
121
this . serviceProxy = options . serviceProxy || null ;
120
122
this . tiandituKey = options . tiandituKey ;
123
+ this . bingMapsKey = options . bingMapsKey || '' ;
121
124
this . googleMapsAPIKey = options . googleMapsAPIKey || '' ;
122
125
this . proxy = options . proxy ;
123
126
//计数叠加图层,处理过的数量(成功和失败都会计数)
@@ -953,7 +956,7 @@ export class WebMap extends Observable {
953
956
source = this . createBaiduSource ( ) ;
954
957
break ;
955
958
case 'BING' :
956
- source = this . createBingSource ( layerInfo , layerInfo . projection ) ;
959
+ source = this . createBingSource ( ) ;
957
960
break ;
958
961
case 'WMS' :
959
962
source = this . createWMSSource ( layerInfo ) ;
@@ -1292,32 +1295,14 @@ export class WebMap extends Observable {
1292
1295
* @private
1293
1296
* @function WebMap.prototype.createBingSource
1294
1297
* @description 创建bing地图的source。
1295
- * @returns {ol.source.XYZ } bing地图的source
1298
+ * @returns {ol.source.BingMaps } bing地图的source
1296
1299
*/
1297
- createBingSource ( layerInfo , projection ) {
1298
- let url =
1299
- 'https://dynamic.t0.tiles.ditu.live.com/comp/ch/{quadKey}?it=G,TW,L,LA&mkt=zh-cn&og=109&cstl=w4c&ur=CN&n=z' ;
1300
- return new XYZ ( {
1301
- wrapX : false ,
1302
- projection : projection ,
1303
- crossOrigin : 'anonymous' ,
1304
- tileUrlFunction : function ( coordinates ) {
1305
- let /*quadDigits = '', */ [ z , x , y ] = [ ...coordinates ] ;
1306
- y = y > 0 ? y - 1 : - y - 1 ;
1307
- let index = '' ;
1308
- for ( let i = z ; i > 0 ; i -- ) {
1309
- let b = 0 ;
1310
- let mask = 1 << ( i - 1 ) ;
1311
- if ( ( x & mask ) !== 0 ) {
1312
- b ++ ;
1313
- }
1314
- if ( ( y & mask ) !== 0 ) {
1315
- b += 2 ;
1316
- }
1317
- index += b . toString ( ) ;
1318
- }
1319
- return url . replace ( '{quadKey}' , index ) ;
1320
- }
1300
+ createBingSource ( ) {
1301
+ return new BingMaps ( {
1302
+ key : this . bingMapsKey ,
1303
+ imagerySet : 'RoadOnDemand' ,
1304
+ culture : 'zh-cn' ,
1305
+ wrapX : false
1321
1306
} ) ;
1322
4106
1307
}
1323
1308
0 commit comments