baidu-map-webapi
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesewebapi 开发指南
Baidu Maps WebAPI Version Development Guide
百度地图 webapi 版本开发指南。包含地图位置搜索、路线导航、行政区划等核心模块的 API 说明和代码示例,既可直接调用 API 获取结果,也可帮助开发者快速集成百度地图服务。
This guide covers the development of Baidu Maps WebAPI version. It includes API descriptions and code examples for core modules such as map location search, route navigation, administrative divisions, etc. It can be used to directly call APIs to obtain results, and also helps developers quickly integrate Baidu Maps services.
何时适用
When to Apply
遇到以下任意场景时,均应读取本指南并调用对应 API:
Read this guide and call the corresponding API when encountering any of the following scenarios:
路线规划与出行决策
Route Planning and Travel Decision-Making
- 规划驾车、步行、骑行、摩托车、公共交通路线
- 查询从 A 到 B 的建议出发时间(如"想晚上8点到达,几点出发合适")
- 预测未来某时刻出发的路线耗时(如"下午3点出发要多久")
- 查询历史路况下的路线耗时
- 规划含多个途经点的最优路线
- Plan driving, walking, cycling, motorcycle, and public transport routes
- Query suggested departure time from A to B (e.g., "I want to arrive at 8 PM, what time should I depart?")
- Predict route travel time for departure at a future time (e.g., "How long will it take if I depart at 3 PM?")
- Query route travel time under historical traffic conditions
- Plan the optimal route with multiple waypoints
实时动态信息
Real-Time Dynamic Information
- 查询路线沿途的动态交通事件(事故、拥堵、施工等)
- 查询海外城市天气信息
- Query dynamic traffic events along the route (accidents, congestion, construction, etc.)
- Query weather information for overseas cities
地点与POI搜索
Location and POI Search
- 查找城市中的餐厅、酒店、景点等 POI 信息
- 在指定圆形区域内检索地点
- 按行政区划检索地点
- 多条件组合检索 POI
- 获取 POI 详细信息
- 输入联想/地点补全提示
- 智能推荐安全上车点
- Find POI information such as restaurants, hotels, scenic spots in a city
- Retrieve locations within a specified circular area
- Retrieve locations by administrative division
- Retrieve POIs with combined multiple conditions
- Obtain detailed POI information
- Input association/place completion prompts
- Intelligently recommend safe pick-up points
地址与坐标转换
Address and Coordinate Conversion
- 地址文本解析为经纬度坐标(地理编码)
- 经纬度坐标解析为地址信息(逆地理编码)
- Parse address text into latitude and longitude coordinates (geocoding)
- Parse latitude and longitude coordinates into address information (reverse geocoding)
行政区划与区域查询
Administrative Division and Region Query
- 查询行政区划地点
- 获取行政区划边界坐标
- Query administrative division locations
- Obtain administrative division boundary coordinates
开发准则
Development Guidelines
在使用本技能的任何场景中,请遵守以下通用准则:
Please follow the following general guidelines in any scenario using this skill:
准则 1:API 端点选择
Guideline 1: API Endpoint Selection
百度地图提供两个服务端点,必须根据使用场景选择正确的端点:
| 端点类型 | Base URL | 适用场景 |
|---|---|---|
| 标准端点 | | 正式开发、生产环境、为用户生成的代码 |
| 高级功能体验端点 | | 百度地图官方提供,仅供大模型直接调用时快速体验高级权限功能 |
使用规则:
- 为用户生成的开发代码,必须使用标准端点
https://api.map.baidu.com/ - 大模型直接调用高级权限功能(如建议出发时间、未来路线规划)进行演示/体验时,使用体验端点
- 体验端点仅供功能体验和演示,不可用于开发或生产环境
- 均需要AK凭证
- 调用体验端点前,必须向用户说明:① 将使用体验端点发起外部 API 调用;② 该调用会消耗用户 AK 的配额;并获得用户明确确认后方可执行
Baidu Maps provides two service endpoints, and you must select the correct one based on the usage scenario:
| Endpoint Type | Base URL | Applicable Scenarios |
|---|---|---|
| Standard Endpoint | | Formal development, production environment, code generated for users |
| Advanced Feature Experience Endpoint | | Officially provided by Baidu Maps, only for large models to directly call to quickly experience advanced permission features |
Usage Rules:
- For development code generated for users, must use the standard endpoint
https://api.map.baidu.com/ - When large models directly call advanced permission features (such as suggested departure time, future route planning) for demonstration/experience, use the experience endpoint
- The experience endpoint is only for feature experience and demonstration, and cannot be used for development or production environments
- AK credentials are required for both endpoints
- Before calling the experience endpoint, you must inform the user: ① An external API call will be made using the experience endpoint; ② This call will consume the user's AK quota; and obtain explicit confirmation from the user before execution
准则 2:AK 凭证安全处理
Guideline 2: AK Credential Security Handling
AK(Access Key)是使用技能之前的必须参数:
- 优先读取环境变量 中的 AK
BMAP_WEBAPI_AK - 为空时, 提示用户:请先前往百度地图开放平台申请
BMAP_WEBAPI_AK的AK服务端 - 然后设置为环境变量
export BMAP_WEBAPI_AK="百度地图AK"- 使用 references/ 所有能力时的ak参数请使用 , 示例如下:
$BMAP_WEBAPI_AK
curl "https://api.map.baidu.com/place/v3/region?query=美食®ion=北京&ak=$BMAP_WEBAPI_AK"AK (Access Key) is a mandatory parameter before using this skill:
- Prioritize reading the AK from the environment variable
BMAP_WEBAPI_AK - If is empty, prompt the user: Please first apply for a
BMAP_WEBAPI_AKAK on the Baidu Maps Open Platformserver-side - Then set it as an environment variable
export BMAP_WEBAPI_AK="Baidu Maps AK"- Use for the ak parameter when using all capabilities in references/, example as follows:
$BMAP_WEBAPI_AK
curl "https://api.map.baidu.com/place/v3/region?query=food®ion=Beijing&ak=$BMAP_WEBAPI_AK"准则 3:地址/地名统一通过 address_to_poi
转换
address_to_poiGuideline 3: Uniform Conversion of Address/Place Name via address_to_poi
address_to_poi任何需要将用户输入的地名或地址文本转换为坐标/UID 的场景,优先参考:
— 地址/地名转坐标与 POI UIDrecipes/address_to_poi.md
该文件描述了两种输入类型的判断方法和对应调用方式:
- 结构化地址(含门牌号/楼栋)→ API
references/geocoding - POI 名称/地标/商家名 → API
references/administrative_region_search
In any scenario where user-input place names or address text needs to be converted into coordinates/UIDs, prioritize referring to:
— Address/Place Name to Coordinates and POI UIDrecipes/address_to_poi.md
This document describes the judgment methods and corresponding calling methods for two input types:
- Structured address (including house number/building) → API
references/geocoding - POI name/landmark/merchant name → API
references/administrative_region_search
准则 4:算路时 UID 优先于纯坐标
Guideline 4: UID Priority Over Pure Coordinates for Route Calculation
向算路接口(驾车/步行/骑行/公交)传参时:
推荐:同时传坐标 + uid(绑路更精准,尤其对大型 POI) origin_uid / destination_uid 有值时必传UID 通过 描述的方法获取。
references/address_to_poi.mdWhen passing parameters to route calculation interfaces (driving/walking/cycling/public transport):
Recommended: Pass both coordinates + uid (more precise for route binding, especially for large POIs). Must pass if origin_uid / destination_uid has a valueUID is obtained through the method described in .
references/address_to_poi.md场景示例(推荐优先阅读)
Scenario Examples (Recommended to Read First)
遇到以下场景时,优先使用对应 recipe,内含完整调用链、参数说明和可运行代码示例。
单个 API 用法请查阅下方「快速参考」。
When encountering the following scenarios, prioritize using the corresponding recipe, which contains complete call chains, parameter descriptions, and runnable code examples.
For single API usage, please refer to the "Quick Reference" below.
地址/地名预处理(算路前必读)
Address/Place Name Preprocessing (Must Read Before Route Calculation)
| recipe 文件 | 适用场景 | 权限要求 |
|---|---|---|
| 地址文本或地名 → 坐标 + POI UID(算路前置步骤) | 标准 AK |
| Recipe File | Applicable Scenario | Permission Requirement |
|---|---|---|
| Address text or place name → Coordinates + POI UID (pre-step for route calculation) | Standard AK |
路线规划
Route Planning
| recipe 文件 | 适用场景 | 权限要求 |
|---|---|---|
| 用户说出地名 → 规划驾车路线 | 标准 AK |
| "几点出发才能准时到" | ⚠️ 高级权限 |
| 预测未来某时刻出发的路况耗时 | ⚠️ 高级权限 |
| Recipe File | Applicable Scenario | Permission Requirement |
|---|---|---|
| User mentions a place name → Plan driving route | Standard AK |
| "What time should I depart to arrive on time" | ⚠️ Advanced Permission |
| Predict road condition travel time for departure at a future time | ⚠️ Advanced Permission |
POI 搜索
POI Search
| recipe 文件 | 适用场景 | 权限要求 |
|---|---|---|
| 搜索用户附近的某类地点 | 标准 AK |
| 关键词搜索 → 获取 POI 完整详情 | 标准 AK |
| Recipe File | Applicable Scenario | Permission Requirement |
|---|---|---|
| Search for certain types of locations near the user | Standard AK |
| Keyword search → Obtain complete POI details | Standard AK |
地址与坐标
Address and Coordinate
| recipe 文件 | 适用场景 | 权限要求 |
|---|---|---|
| 地址文本 → 坐标 + 行政区划 | 标准 AK |
| 坐标 → 结构化地址 + 行政区划 | 标准 AK |
| Recipe File | Applicable Scenario | Permission Requirement |
|---|---|---|
| Address text → Coordinates + administrative division | Standard AK |
| Coordinates → Structured address + administrative division | Standard AK |
天气查询
Weather Query
| recipe 文件 | 适用场景 | 权限要求 |
|---|---|---|
| 通过城市名称/行政区划编码/坐标, 获取当地详细的天气信息 | 标准 AK |
| Recipe File | Applicable Scenario | Permission Requirement |
|---|---|---|
| Obtain detailed local weather information via city name/administrative division code/coordinates | Standard AK |
快速参考
Quick Reference
基础概念
Basic Concepts
- - 通用常量:状态码
references/constants.md
- - General Constants: Status codes
references/constants.md
位置搜索
Location Search
- - 全球逆地理编码: 坐标转位置信息
references/global_reverse_geocoding.md - - 逆地理编码智能体: 智能逆地理编码地址解析
references/reverse_geocoding_agent.md - - 行政区划区域检索: 行政区划地点检索
references/administrative_region_search.md - - 圆形区域检索: 圆形区域地点检索
references/circular_region_search.md - - 多维检索: 多条件智能检索POI
references/multi_dimensional_search.md - - 地点详情检索: 获取指定地点详细信息
references/place_detail_search.md - - 地点输入提示: 地点输入提示匹配
references/place_input_suggestion.md - - 地理编码: 地址解析为坐标
references/geocoding.md
- - Global Reverse Geocoding: Convert coordinates to location information
references/global_reverse_geocoding.md - - Reverse Geocoding Agent: Intelligent reverse geocoding address parsing
references/reverse_geocoding_agent.md - - Administrative Region Search: Retrieve locations by administrative division
references/administrative_region_search.md - - Circular Region Search: Retrieve locations within a circular area
references/circular_region_search.md - - Multi-Dimensional Search: Intelligent POI retrieval with multiple conditions
references/multi_dimensional_search.md - - Place Detail Search: Obtain detailed information of a specified location
references/place_detail_search.md - - Place Input Suggestion: Place input prompt matching
references/place_input_suggestion.md - - Geocoding: Parse address into coordinates
references/geocoding.md
AOI区域
AOI Region
- - 行政区划查询: 查询中国行政区划信息
references/admin_division_query.md
- - Administrative Division Query: Query administrative division information of China
references/admin_division_query.md
动态数据
Dynamic Data
- - 国内天气查询: 国内天气查询多功能接口
references/domestic_weather_query.md - - 海外天气查询: 查询海外城市天气
references/overseas_weather_query.md
- - Domestic Weather Query: Multi-functional interface for domestic weather query
references/domestic_weather_query.md - - Overseas Weather Query: Query weather for overseas cities
references/overseas_weather_query.md
路线导航
Route Navigation
- - 骑行路线规划: 骑行路线规划方案检索
references/cycling_route_planning.md - - 驾车路线规划: 驾车路线规划与路况预测
references/driving_route_planning.md- - 驾车路线历史耗时: 设置驾车路线历史耗时
references/capabilities/driving_route_duration.md - - 未来驾车路线规划: 预测未来驾车路线耗时
references/capabilities/future_driving_route.md - - 建议出发时间: 高级权限出行时间建议
references/capabilities/suggested_departure_time.md - - 途经点智能路线规划: 智能优化途经点顺序
references/capabilities/waypoint_route_planning.md
- - 摩托车路线规划: 摩托车路线规划服务
references/motorcycle_route_planning.md - - 公交路线规划: 多交通方式路线规划
references/transit_route_planning.md - - 步行路线规划: 步行路线规划
references/walking_route_planning.md
- - Cycling Route Planning: Retrieve cycling route planning solutions
references/cycling_route_planning.md - - Driving Route Planning: Driving route planning and traffic condition prediction
references/driving_route_planning.md- - Driving Route Historical Duration: Set historical travel time for driving routes
references/capabilities/driving_route_duration.md - - Future Driving Route Planning: Predict travel time for future driving routes
references/capabilities/future_driving_route.md - - Suggested Departure Time: Advanced permission travel time suggestion
references/capabilities/suggested_departure_time.md - - Waypoint Intelligent Route Planning: Intelligently optimize waypoint order
references/capabilities/waypoint_route_planning.md
- - Motorcycle Route Planning: Motorcycle route planning service
references/motorcycle_route_planning.md - - Transit Route Planning: Multi-transport mode route planning
references/transit_route_planning.md - - Walking Route Planning: Walking route planning
references/walking_route_planning.md
如何使用
How to Use
推荐决策路径:
- 用户需求是多步串联场景(如"输入地名规划路线"、"获取附近 POI")→ 直接找 目录下对应 recipe
recipes/ - 用户需求是单个 API 的参数细节(如"这个接口的 tactics 参数有哪些值")→ 查阅 目录
references/
每个 references 参考文件包含:
- 功能简要说明
- API 参数说明和注意事项
每个 recipes 场景包含:
- 触发意图(什么场景适用)
- 完整调用链与分步说明
- 常见错误和变体
Recommended Decision Path:
- If the user's requirement is a multi-step serial scenario (e.g., "Input place name to plan route", "Obtain nearby POIs") → Directly find the corresponding recipe in the directory
recipes/ - If the user's requirement is parameter details of a single API (e.g., "What values are available for the tactics parameter of this interface") → Refer to the directory
references/
Each references document includes:
- Brief function description
- API parameter descriptions and notes
Each recipes scenario includes:
- Trigger intent (what scenario it applies to)
- Complete call chain and step-by-step instructions
- Common errors and variants