8000 update 修改 ol webmap bing 地图数据源 review by luox · SuperMap/iClient-JavaScript@283d129 · GitHub
[go: up one dir, main page]

Skip to content

Commit 283d129

Browse files
update 修改 ol webmap bing 地图数据源 review by luox
1 parent 1a46807 commit 283d129

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import * as olGeometry from 'ol/geom';
3737
import Vector from 'ol/source/Vector';
3838
import XYZ from 'ol/source/XYZ';
3939
import WMTS from 'ol/source/WMTS';
40+
import BingMaps from 'ol/source/BingMaps';
4041
import TileWMS from 'ol/source/TileWMS';
4142
import Feature from 'ol/Feature';
4243
import olRenderFeature from 'ol/render/Feature';
@@ -86,6 +87,7 @@ const dpiConfig = {
8687
* @param {boolean} [options.excludePortalProxyUrl] - server 传递过来的 URL 是否带有代理。
8788
* @param {Object} [options.serviceProxy] - SuperMap iPortal 内置代理信息,仅矢量瓦片图层上图才会使用。
8889
* @param {string} [options.tiandituKey] - 天地图的 key。
90+
* @param {string} [options.bingMapsKey] - 必应地图的 key。
8991
* @param {string} [options.googleMapsAPIKey] - 谷歌底图需要的 key。
9092
* @param {string} [options.proxy] - 代理地址,当域名不一致,请求会加上代理。避免跨域。
9193
* @param {string} [options.tileFormat] - 地图瓦片出图格式,png/webp。
@@ -118,6 +120,7 @@ export class WebMap extends Observable {
118120
this.excludePortalProxyUrl = options.excludePortalProxyUrl || false;
119121
this.serviceProxy = options.serviceProxy || null;
120122
this.tiandituKey = options.tiandituKey;
123+
this.bingMapsKey = options.bingMapsKey || '';
121124
this.googleMapsAPIKey = options.googleMapsAPIKey || '';
122125
this.proxy = options.proxy;
123126
//计数叠加图层,处理过的数量(成功和失败都会计数)
@@ -953,7 +956,7 @@ export class WebMap extends Observable {
953956
source = this.createBaiduSource();
954957
break;
955958
case 'BING':
956-
source = this.createBingSource(layerInfo, layerInfo.projection);
959+
source = this.createBingSource();
957960
break;
958961
case 'WMS':
959962
source = this.createWMSSource(layerInfo);
@@ -1292,32 +1295,14 @@ export class WebMap extends Observable {
12921295
* @private
12931296
* @function WebMap.prototype.createBingSource
12941297
* @description 创建bing地图的source。
1295-
* @returns {ol.source.XYZ} bing地图的source
1298+
* @returns {ol.source.BingMaps} bing地图的source
12961299
*/
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
13211306
});
1322 4106 1307
}
13231308

0 commit comments

Comments
 (0)
0