@@ -42,6 +42,7 @@ import * as olGeometry from 'ol/geom';
42
42
import Vector from 'ol/source/Vector' ;
43
43
import XYZ from 'ol/source/XYZ' ;
44
44
import WMTS from 'ol/source/WMTS' ;
45
+ import BingMaps from 'ol/source/BingMaps' ;
45
46
import TileWMS from 'ol/source/TileWMS' ;
46
47
import Feature from 'ol/Feature' ;
47
48
import olRenderFeature from 'ol/render/Feature' ;
@@ -91,6 +92,7 @@ const dpiConfig = {
91
92
* @param {boolean } [options.excludePortalProxyUrl] - server传递过来的url是否带有代理
92
93
* @param {Object } [options.serviceProxy] - iportal内置代理信息, 仅矢量瓦片图层上图才会使用
93
94
* @param {string } [options.tiandituKey] - 天地图的key
95
+ * @param {string } [options.bingMapsKey] - 必应地图的 key。
94
96
* @param {string } [options.googleMapsAPIKey] - 谷歌底图需要的key
95
97
* @param {string } [options.proxy] - 代理地址,当域名不一致,请求会加上代理。避免跨域
96
98
* @param {string } [options.tileFormat] - 地图瓦片出图格式,png/webp
@@ -124,6 +126,7 @@ export class WebMap extends Observable {
124
126
this . excludePortalProxyUrl = options . excludePortalProxyUrl || false ;
125
127
this . serviceProxy = options . serviceProxy || null ;
126
128
this . tiandituKey = options . tiandituKey ;
129
+ this . bingMapsKey = options . bingMapsKey || '' ;
127
130
this . googleMapsAPIKey = options . googleMapsAPIKey || '' ;
128
131
this . proxy = options . proxy ;
129
132
//计数叠加图层,处理过的数量(成功和失败都会计数)
@@ -902,7 +905,7 @@ export class WebMap extends Observable {
902
905
source = this . createBaiduSource ( ) ;
903
906
break ;
904
907
case 'BING' :
905
- source = this . createBingSource ( layerInfo , layerInfo . projection ) ;
908
+ source = this . createBingSource ( ) ;
906
909
break ;
907
910
case "WMS" :
908
911
source = this . createWMSSource ( layerInfo ) ;
@@ -1230,32 +1233,15 @@ export class WebMap extends Observable {
1230
1233
* @private
1231
1234
* @function WebMap.prototype.createBingSource
1232
1235
* @description 创建bing地图的source。
1233
- * @returns {ol.source.XYZ } bing地图的source
1234
- */
1235
- createBingSource ( layerInfo , projection ) {
1236
- let url = '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' ;
1237
- return new XYZ ( {
1238
- wrapX : false ,
1239
- projection : projection ,
1240
- crossOrigin : 'anonymous' ,
1241
- tileUrlFunction : function ( coordinates ) {
1242
- let /*quadDigits = '', */ [ z , x , y ] = [ ...coordinates ] ;
1243
- y = y > 0 ? y - 1 : - y - 1 ;
1244
- let index = '' ;
1245
- for ( let i = z ; i > 0 ; i -- ) {
1246
- let b = 0 ;
1247
- let mask = 1 << ( i - 1 ) ;
1248
- if ( ( x & mask ) !== 0 ) {
1249
- b ++ ;
1250
- }
1251
- if ( ( y & mask ) !== 0 ) {
1252
- b += 2 ;
1253
- }
1254
- index += b . toString ( )
1255
- }
1256
- return url . replace ( '{quadKey}' , index ) ;
1257
- }
1258
- } )
1236
+ * @returns {ol.source.BingMaps } bing地图的source
1237
+ */
1238
+ createBingSource ( ) {
1239
+ return new BingMaps ( {
1240
+ key : this . bingMapsKey ,
1241
+ imagerySet : 'RoadOnDemand' ,
1242
+ culture : 'zh-cn' ,
1243
+ wrapX : false
1244
+ } ) ;
1259
1245
}
1260
1246
1261
1247
/**
0 commit comments