Просмотр исходного кода

修正高德地图Web端JS API Key

gmXian 6 месяцев назад
Родитель
Сommit
2e695f3a6f

+ 3 - 2
code/chapter13/helloagents-trip-planner/README.md

@@ -64,7 +64,7 @@ helloagents-trip-planner/
 
 - Python 3.10+
 - Node.js 16+
-- 高德地图API密钥 (Web服务API)
+- 高德地图API密钥 (Web服务API和Web端(JS API))
 - LLM API密钥 (OpenAI/DeepSeek等)
 
 ### 后端安装
@@ -110,8 +110,9 @@ npm install
 
 3. 配置环境变量
 ```bash
-# 创建.env文件,配置高德地图Web API Key
+# 创建.env文件,配置高德地图Web API Key和Web端JS API Key
 echo "VITE_AMAP_WEB_KEY=your_amap_web_key" > .env
+echo "VITE_AMAP_WEB_JS_KEY=your)amap_web_js_key" > .env
 ```
 
 4. 启动开发服务器

+ 1 - 1
code/chapter13/helloagents-trip-planner/frontend/src/views/Result.vue

@@ -833,7 +833,7 @@ const restoreMap = () => {
 const initMap = async () => {
   try {
     const AMap = await AMapLoader.load({
-      key: '25dfaf050fe024803e96badd370e8029', // 高德地图Web服务API Key
+      key: import.meta.env.VITE_AMAP_WEB_JS_KEY, // 高德地图Web端(JS API) Key
       version: '2.0',
       plugins: ['AMap.Marker', 'AMap.Polyline', 'AMap.InfoWindow']
     })