From 6e12219a31da1cb5a3a558a64f79a031365a95ec Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 26 Feb 2026 13:56:31 +0800 Subject: [PATCH] =?UTF-8?q?Map=E7=BB=84=E4=BB=B6=E6=94=B9=E6=88=90?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=A4=96=E9=83=A8=E6=8F=90=E4=BE=9B=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E5=9C=B0=E5=9B=BEAK=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Map/MapSelector.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Map/MapSelector.js b/src/components/Map/MapSelector.js index bd5d6b7..377b6ab 100644 --- a/src/components/Map/MapSelector.js +++ b/src/components/Map/MapSelector.js @@ -120,14 +120,14 @@ const MapSelector = (props) => { if (!window.BMapGL) { if (window?.base?.loadDynamicResource) { await window.base.loadDynamicResource({ - url: "https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize", + url: `https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`, type: "script", attr: { type: "text/javascript" }, }); initMap(); } else { - await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize"); + await dynamicLoadJs(`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`); initMap(); } } @@ -170,6 +170,10 @@ const MapSelector = (props) => { return; } if (type === "baidu") { + if (!window.mapBaiDuKey) { + console.error("【Map】 请在window设置变量 mapBaiDuKey,以供地图初始化加载使用"); + return; + } loadBaiDuMap(); return; }