Skip to content

Commit 4347d62

Browse files
fix icl-1501 百度地图服务地址错误 review by luox
1 parent a011992 commit 4347d62

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/leaflet/mapping/BaiduTileLayer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Attributions from '../core/Attributions'
1111
* @category ThirdPartyMap
1212
* @modulecategory Mapping
1313
* @extends {L.TileLayer}
14-
* @param {string} [url='https://online3.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20150815&scaler=1'] - 切片地址。
14+
* @param {string} [url='https://maponline{num}.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20150815&scaler=1'] - 切片地址。
1515
* @param {Object} options - 参数。
1616
* @param {number} [options.minZoom=3] - 最小缩放级别。
1717
* @param {number} [options.maxZoom=19] - 最大缩放级别。
@@ -27,7 +27,7 @@ export var BaiduTileLayer = L.TileLayer.extend({
2727
* @member {string} BaiduTileLayer.prototype.url
2828
* @description 切片地址。
2929
*/
30-
url: "https://online3.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20150815&scaler=1",
30+
url: "https://maponline{num}.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20150815&scaler=1",
3131

3232
options: {
3333
minZoom: 3,
@@ -56,7 +56,7 @@ export var BaiduTileLayer = L.TileLayer.extend({
5656
*/
5757
getTileUrl: function (coords) {
5858
var url = L.Util.template(this.url, {
59-
num: Math.abs((coords.x + coords.y) % 8) + 1,
59+
num: Math.abs((coords.x + coords.y) % 4),
6060
x: coords.x,
6161
y: -coords.y - 1,
6262
z: this._getZoomForUrl(),

src/openlayers/mapping/BaiduMap.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Util } from '../core/Util';
1313
* @classdesc 百度地图图层源。
1414
* @modulecategory Mapping
1515
* @param {Object} opt_options - 参数。
16-
* @param {string} [opt_options.url='https://online3.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20170408'] - 服务地址。
16+
* @param {string} [opt_options.url='https://maponline{num}.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20170408'] - 服务地址。
1717
* @param {string} [opt_options.tileProxy] - 代理地址。
1818
* @param {boolean} [hidpi = false] - 是否使用高分辨率地图。
1919
* @extends {ol.source.TileImage}
@@ -31,7 +31,7 @@ export class BaiduMap extends TileImage {
3131
var url =
3232
options.url !== undefined
3333
? options.url
34-
: 'https://online3.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20170408';
34+
: 'https://maponline{num}.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles={styles}&udt=20170408';
3535
var hidpi =
3636
options.hidpi || (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1;
3737
url = url.replace('{styles}', hidpi ? 'ph' : 'pl');
@@ -58,6 +58,7 @@ export class BaiduMap extends TileImage {
5858
// eslint-disable-next-line no-unused-vars
5959
function tileUrlFunction(tileCoord, pixelRatio, projection) {
6060
var tempUrl = url
61+
.replace('{num}', Math.abs((tileCoord[1] + tileCoord[2]) % 4))
6162
.replace('{z}', tileCoord[0].toString())
6263
.replace('{x}', tileCoord[1].toString())
6364
.replace('{y}', function() {

0 commit comments

Comments
 (0)