Google Maps 🗺️
Google Maps integration powered by the Routes API.
Requirements
- -
GOOGLE_API_KEY environment variable - Enable in Google Cloud Console: Routes API, Places API, Geocoding API
- Python package:
requests (pip install requests)
Configuration
| Env Variable | Default | Description |
|---|
| INLINECODE3 | - | Required. Your Google Maps API key |
| INLINECODE4 |
- | Alternative to
GOOGLE_API_KEY (fallback) |
|
GOOGLE_MAPS_LANG |
en | Response language (en, he, ja, etc.) |
Set in OpenClaw config:
CODEBLOCK0
Script Location
CODEBLOCK1
Actions
distance - Calculate travel time
CODEBLOCK2
Options:
| Option | Values | Description |
|---|
| INLINECODE8 | driving, walking, bicycling, transit | Travel mode (default: driving) |
| INLINECODE9 |
now, +30m, +1h, 14:00, 2026-02-07 08:00 | Departure time |
|
--arrive | 14:00 | Arrival time (transit only) |
|
--traffic | best_guess, pessimistic, optimistic | Traffic model |
|
--avoid | tolls, highways, ferries | Comma-separated |
Examples:
CODEBLOCK3
Response:
{
"distance": "215.2 mi",
"distance_meters": 346300,
"duration": "3 hrs 45 mins",
"duration_seconds": 13500,
"static_duration": "3 hrs 30 mins",
"duration_in_traffic": "3 hrs 45 mins"
}
directions - Turn-by-turn route
CODEBLOCK5
Additional options (beyond distance):
| Option | Description |
|---|
| INLINECODE13 | Return multiple routes |
| INLINECODE14 |
Intermediate stops (pipe-separated) |
|
--optimize | Optimize waypoint order (TSP) |
Examples:
CODEBLOCK6
Response includes: summary, labels, duration, staticduration, warnings, steps[], optimizedwaypoint_order
matrix - Distance matrix
Calculate distances between multiple origins and destinations:
CODEBLOCK7
Example:
CODEBLOCK8
Response:
{
"origins": ["New York", "Boston"],
"destinations": ["Philadelphia", "Washington DC"],
"results": [
{"origin_index": 0, "destination_index": 0, "distance": "97 mi", "duration": "1 hr 45 mins"},
{"origin_index": 0, "destination_index": 1, "distance": "225 mi", "duration": "4 hrs 10 mins"}
]
}
geocode - Address to coordinates
CODEBLOCK10
reverse - Coordinates to address
CODEBLOCK11
search - Find places
CODEBLOCK12
details - Place information
CODEBLOCK13
Traffic Models
| Model | Use Case |
|---|
| INLINECODE16 | Default balanced estimate |
| INLINECODE17 |
Important meetings (worst-case) |
|
optimistic | Best-case scenario |
Regional Notes
Some features may not be available in all countries:
| Feature | Availability |
|---|
| INLINECODE19 | US, EU, select countries |
| INLINECODE20 |
Limited availability |
|
--mode=two_wheeler | Asia, select countries |
Check Google Maps coverage for details.
Multilingual Support
Works with addresses in any language:
CODEBLOCK14
Language configuration:
- 1. Set default via env:
GOOGLE_MAPS_LANG=he (persists) - Override per-request: INLINECODE23
CODEBLOCK15
Help
CODEBLOCK16
Google Maps 🗺️
基于 Routes API 的 Google Maps 集成。
要求
- - GOOGLEAPIKEY 环境变量
- 在 Google Cloud Console 中启用:Routes API、Places API、Geocoding API
- Python 包:requests(pip install requests)
配置
| 环境变量 | 默认值 | 描述 |
|---|
| GOOGLEAPIKEY | - | 必填。您的 Google Maps API 密钥 |
| GOOGLEMAPSAPIKEY |
- | GOOGLEAPI_KEY 的替代方案(备用) |
| GOOGLE
MAPSLANG | en | 响应语言(en、he、ja 等) |
在 OpenClaw 配置中设置:
json
{
env: {
GOOGLEAPIKEY: AIza...,
GOOGLEMAPSLANG: en
}
}
脚本位置
bash
python3 skills/google-maps/lib/map_helper.py [options]
操作
distance - 计算行程时间
bash
python3 skills/google-maps/lib/map_helper.py distance 起点 终点 [options]
选项:
| 选项 | 值 | 描述 |
|---|
| --mode | driving、walking、bicycling、transit | 出行方式(默认:driving) |
| --depart |
now、+30m、+1h、14:00、2026-02-07 08:00 | 出发时间 |
| --arrive | 14:00 | 到达时间(仅限 transit) |
| --traffic | best_guess、pessimistic、optimistic | 交通模型 |
| --avoid | tolls、highways、ferries | 逗号分隔 |
示例:
bash
python3 skills/google-maps/lib/map_helper.py distance 纽约 波士顿
python3 skills/google-maps/lib/map_helper.py distance 洛杉矶 旧金山 --depart=+1h
python3 skills/google-maps/lib/map_helper.py distance 芝加哥 底特律 --depart=08:00 --traffic=pessimistic
python3 skills/google-maps/lib/map_helper.py distance 伦敦 曼彻斯特 --mode=transit --arrive=09:00
python3 skills/google-maps/lib/map_helper.py distance 巴黎 里昂 --avoid=tolls,highways
响应:
json
{
distance: 215.2 mi,
distance_meters: 346300,
duration: 3 hrs 45 mins,
duration_seconds: 13500,
static_duration: 3 hrs 30 mins,
durationintraffic: 3 hrs 45 mins
}
directions - 逐向导航路线
bash
python3 skills/google-maps/lib/map_helper.py directions 起点 终点 [options]
附加选项(除 distance 外):
| 选项 | 描述 |
|---|
| --alternatives | 返回多条路线 |
| --waypoints |
中途停靠点(竖线分隔) |
| --optimize | 优化途经点顺序(TSP) |
示例:
bash
python3 skills/google-maps/lib/map_helper.py directions 纽约 华盛顿特区
python3 skills/google-maps/lib/map_helper.py directions 旧金山 洛杉矶 --alternatives
python3 skills/google-maps/lib/map_helper.py directions 迈阿密 奥兰多 --waypoints=劳德代尔堡|西棕榈滩 --optimize
响应包含: 摘要、标签、时长、静态时长、警告、步骤[]、优化后的途经点顺序
matrix - 距离矩阵
计算多个起点和终点之间的距离:
bash
python3 skills/google-maps/lib/map_helper.py matrix 起点1|起点2 终点1|终点2
示例:
bash
python3 skills/google-maps/lib/map_helper.py matrix 纽约|波士顿 费城|华盛顿特区
响应:
json
{
origins: [纽约, 波士顿],
destinations: [费城, 华盛顿特区],
results: [
{originindex: 0, destinationindex: 0, distance: 97 mi, duration: 1 hr 45 mins},
{originindex: 0, destinationindex: 1, distance: 225 mi, duration: 4 hrs 10 mins}
]
}
geocode - 地址转坐标
bash
python3 skills/google-maps/lib/map_helper.py geocode 1600 Amphitheatre Parkway, Mountain View, CA
python3 skills/google-maps/lib/map_helper.py geocode 唐宁街10号,伦敦
reverse - 坐标转地址
bash
python3 skills/google-maps/lib/map_helper.py reverse 40.7128 -74.0060 # 纽约市
python3 skills/google-maps/lib/map_helper.py reverse 51.5074 -0.1278 # 伦敦
search - 查找地点
bash
python3 skills/google-maps/lib/map_helper.py search 时代广场附近的咖啡
python3 skills/google-maps/lib/map_helper.py search 旧金山的药店 --open
details - 地点信息
bash
python3 skills/google-maps/lib/maphelper.py details id>
交通模型
| 模型 | 使用场景 |
|---|
| best_guess | 默认平衡估算 |
| pessimistic |
重要会议(最坏情况) |
| optimistic | 最佳情况 |
区域说明
某些功能可能并非在所有国家/地区可用:
| 功能 | 可用性 |
|---|
| --fuel-efficient | 美国、欧盟、特定国家 |
| --shorter |
有限可用性 |
| --mode=two_wheeler | 亚洲、特定国家 |
详情请查看 Google Maps 覆盖范围。
多语言支持
支持任何语言的地址:
bash
希伯来语
python3 skills/google-maps/lib/map_helper.py distance תל אביב ירושלים
python3 skills/google-maps/lib/map_helper.py geocode דיזנגוף 50, תל אביב
日语
python3 skills/google-maps/lib/map_helper.py distance 東京 大阪
阿拉伯语
python3 skills/google-maps/lib/map_helper.py distance دبي أبو ظبي
语言配置:
- 1. 通过环境变量设置默认值:GOOGLEMAPSLANG=he(持久化)
- 每次请求覆盖:--lang=ja
bash
在 OpenClaw 配置中将希伯来语设为默认值
GOOGLE
MAPSLANG=he
覆盖特定请求
python3 skills/google-maps/lib/map_helper.py distance 东京 大阪 --lang=ja
帮助
bash
python3 skills/google-maps/lib/map_helper.py help