فهرست منبع

Merge pull request #246 from gmXian/fix_amap_web_js_api

Fix amap web js api
jjyaoao 5 ماه پیش
والد
کامیت
7658109af7

+ 3 - 3
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,8 @@ npm install
 
 3. 配置环境变量
 ```bash
-# 创建.env文件,配置高德地图Web API Key
-echo "VITE_AMAP_WEB_KEY=your_amap_web_key" > .env
+# 创建.env文件, 填入高德地图Web API Key 和 Web端JS API Key
+cp .env.example .env
 ```
 
 4. 启动开发服务器

+ 3 - 1
code/chapter13/helloagents-trip-planner/frontend/.env.example

@@ -2,4 +2,6 @@
 VITE_API_BASE_URL=http://localhost:8000
 
 # 高德地图Web API Key
-VITE_AMAP_WEB_KEY=
+VITE_AMAP_WEB_KEY=your_amap_web_api_key_here
+# 高德地图Web端JS API Key
+VITE_AMAP_WEB_JS_KEY=your_amap_web_js_key_here

+ 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']
     })