From d4b2a08312952009ea1786db7dafc96f6c1e33a3 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 05 十一月 2026 17:39:34 +0800
Subject: [PATCH] fix(map): 换用百度地图 v2.0(普通瓦片),并修掉 BMAP_PROTOCOL 写死 https 的致命 bug
---
public/bmap-test.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/public/bmap-test.html b/public/bmap-test.html
index 879a35b..7d817a7 100644
--- a/public/bmap-test.html
+++ b/public/bmap-test.html
@@ -73,7 +73,7 @@
log('');
// 涓庢寮忎唬鐮佸畬鍏ㄤ竴鑷寸殑鍔犺浇鏂瑰紡
- window.BMAP_PROTOCOL = 'https';
+ window.BMAP_PROTOCOL = window.location.protocol.replace(':', '');
window.BMapGL_loadScriptTime = Date.now();
var url =
'https://api.map.baidu.com/getscript?type=webgl&v=1.0&ak=' +
@@ -485,5 +485,52 @@
document.body.appendChild(s);
})();
</script>
+
+ <hr style="margin:24px 0" />
+ <h3>绗� 9 鍧楋細2D 鍦板浘鐨勭湡瀹炵綉缁滆姹� + DOM 缁撴瀯</h3>
+ <div id="log9" style="padding:12px;background:#fff0f6;border-radius:6px;font-family:Consolas,monospace;font-size:13px;line-height:1.9;white-space:pre-wrap;word-break:break-all"></div>
+ <div id="map6" style="width:100%;height:300px;margin-top:12px;border:1px solid #ddd"></div>
+ <script>
+ (function () {
+ var el = document.getElementById('log9');
+ function lg(m, c) { var d = document.createElement('div'); d.className = c || ''; d.textContent = m; el.appendChild(d); }
+ lg('鍔犺浇 /bmap-sdk2d.js 骞剁洃鍚綉缁滆姹�...');
+ var s = document.createElement('script');
+ s.src = '/bmap-sdk2d.js';
+ s.addEventListener('load', function () {
+ if (!window.BMap) { lg('BMap 鏈氨缁�', 'bad'); return; }
+ var map = new window.BMap.Map('map6');
+ map.centerAndZoom(new window.BMap.Point(116.404, 39.915), 13); // 鍖椾含锛岀‘淇濇湁鐡︾墖
+ map.enableScrollWheelZoom(true);
+ lg('鍦板浘宸插垱寤猴紙鍖椾含 z=13锛�', 'ok');
+
+ setTimeout(function () {
+ var d = document.getElementById('map6');
+ lg('');
+ lg('=== 瀹瑰櫒 DOM 缁撴瀯 ===');
+ lg('innerHTML 闀垮害: ' + d.innerHTML.length);
+ lg('瀛愬厓绱犳暟: ' + d.children.length);
+ lg('img 鏁�: ' + d.querySelectorAll('img').length);
+ lg('canvas 鏁�: ' + d.querySelectorAll('canvas').length);
+ lg('innerHTML 鍓� 600 瀛楃:');
+ lg(d.innerHTML.slice(0, 600));
+ lg('');
+ lg('=== 鐪熷疄缃戠粶璇锋眰锛堝惈鐡︾墖锛�===');
+ var rs = performance.getEntriesByType('resource');
+ var tile = rs.filter(function (r) { return /bmap-tile|bdimg|maponline|bmap-api/.test(r.name); });
+ lg('鐩稿叧璇锋眰鎬绘暟: ' + tile.length + '锛堥〉闈㈡�昏姹� ' + rs.length + '锛�');
+ tile.slice(0, 25).forEach(function (r) {
+ var sz = r.transferSize || r.encodedBodySize || 0;
+ var st = r.responseStatus || (sz > 0 ? 200 : '?');
+ lg(' [' + st + '] ' + (Math.round(r.duration)) + 'ms ' + sz + 'B ' + r.name.slice(0, 120), sz > 0 ? '' : 'bad');
+ });
+ if (tile.length === 0) {
+ lg(' 鈿� 娌℃湁浠讳綍鐡︾墖璇锋眰鍙戝嚭 鈫� SDK 鍐呴儴鐡︾墖 URL 鍙兘浠嶆寚鍚戣 IPv6 鎷︽埅鐨勫師濮嬪煙鍚�', 'bad');
+ }
+ }, 5000);
+ });
+ document.body.appendChild(s);
+ })();
+ </script>
</body>
</html>
--
Gitblit v1.9.3