跳到主要內容

Maps(地圖)

位置智能——地理編碼地點、反向地理編碼座標、查找附近地點(46 種 POI 類別)、駕車/步行/騎行距離與時間、逐嚮導航、時區查詢、命名地點的邊界框與面積,以及在矩形區域內搜索 POI。使用 OpenStreetMap + Overpass + OSRM。免費,無需 API 密鑰。

技能元數據

來源捆綁(默認安裝)
路徑skills/productivity/maps
版本1.2.0
作者Mibayy
許可證MIT
標籤maps, geocoding, places, routing, distance, directions, nearby, location, openstreetmap, nominatim, overpass, osrm

參考:完整 SKILL.md

信息

以下是 Hermes 在觸發此技能時加載的完整技能定義。這是技能激活時代理看到的指令。

Maps 技能

使用免費開放數據源的位置智能。8 個命令,44 種 POI 類別,零依賴(僅使用 Python 標準庫),無需 API 密鑰。

數據源:OpenStreetMap/Nominatim、Overpass API、OSRM、TimeAPI.io。

此技能取代了舊的 find-nearby 技能——find-nearby 的所有功能均由下面的 nearby 命令涵蓋,支持相同的 --near "<place>" 快捷方式和多類別支持。

何時使用

  • 用戶發送 Telegram 位置標記(消息中包含緯度/經度)→ nearby
  • 用戶想要地點名稱的座標 → search
  • 用戶擁有座標並想要地址 → reverse
  • 用戶詢問附近的餐廳、醫院、藥店、酒店等 → nearby
  • 用戶想要駕車/步行/騎行距離或旅行時間 → distance
  • 用戶想要兩個地點之間的逐嚮導航 → directions
  • 用戶想要某位置的時區信息 → timezone
  • 用戶想要在地理區域內搜索 POI → area + bbox

前提條件

Python 3.8+(僅標準庫——無需 pip 安裝)。

腳本路徑:~/.hermes/skills/maps/scripts/maps_client.py

命令

MAPS=~/.hermes/skills/maps/scripts/maps_client.py

search — 地理編碼地點名稱

python3 $MAPS search "Eiffel Tower"
python3 $MAPS search "1600 Pennsylvania Ave, Washington DC"

返回:緯度、經度、顯示名稱、類型、邊界框、重要性評分。

reverse — 座標轉地址

python3 $MAPS reverse 48.8584 2.2945

返回:完整地址細分(街道、城市、州/省、國家、郵政編碼)。

nearby — 按類別查找地點

# By coordinates (from a Telegram location pin, for example)
python3 $MAPS nearby 48.8584 2.2945 restaurant --limit 10
python3 $MAPS nearby 40.7128 -74.0060 hospital --radius 2000

# By address / city / zip / landmark — --near auto-geocodes
python3 $MAPS nearby --near "Times Square, New York" --category cafe
python3 $MAPS nearby --near "90210" --category pharmacy

# Multiple categories merged into one query
python3 $MAPS nearby --near "downtown austin" --category restaurant --category bar --limit 10

46 個類別:restaurant(餐廳)、cafe(咖啡館)、bar(酒吧)、hospital(醫院)、pharmacy(藥店)、hotel(酒店)、guest_house(賓館)、camp_site(露營地)、supermarket(超市)、atm(自動取款機)、gas_station(加油站)、parking(停車場)、museum(博物館)、park(公園)、school(學校)、university(大學)、bank(銀行)、police(警察局)、fire_station(消防站)、library(圖書館)、airport(機場)、train_station(火車站)、bus_stop(公交車站)、church(教堂)、mosque(清真寺)、synagogue(猶太會堂)、dentist(牙醫)、doctor(醫生)、cinema(電影院)、theatre(劇院)、gym(健身房)、swimming_pool(游泳池)、post_office(郵局)、convenience_store(便利店)、bakery(麵包店)、bookshop(書店)、laundry(洗衣店)、car_wash(洗車場)、car_rental(租車行)、bicycle_rental(自行車租賃)、taxi(出租車)、veterinary(獸醫診所)、zoo(動物園)、playground(遊樂場)、stadium(體育場)、nightclub(夜總會)。

每個結果包括:name(名稱)、address(地址)、lat/lon(緯度/經度)、distance_m(距離,米)、maps_url(可點擊的 Google Maps 鏈接)、directions_url(從搜索點出發的 Google Maps 導航鏈接),以及可用時的推廣標籤——cuisine(菜系)、hours(營業時間)、phone(電話)、website(網站)。

distance — 旅行距離和時間

python3 $MAPS distance "Paris" --to "Lyon"
python3 $MAPS distance "New York" --to "Boston" --mode driving
python3 $MAPS distance "Big Ben" --to "Tower Bridge" --mode walking

模式:driving(駕車,默認)、walking(步行)、cycling(騎行)。返回道路距離、持續時間,以及用於比較的直線距離。

directions — 逐嚮導航

python3 $MAPS directions "Eiffel Tower" --to "Louvre Museum" --mode walking
python3 $MAPS directions "JFK Airport" --to "Times Square" --mode driving

返回編號步驟,包含指令、距離、持續時間、道路名稱和機動類型(轉彎、出發、到達等)。

timezone — 座標的時區

python3 $MAPS timezone 48.8584 2.2945
python3 $MAPS timezone 35.6762 139.6503

返回時區名稱、UTC 偏移量和當前本地時間。

area — 地點的邊界框和麵積

python3 $MAPS area "Manhattan, New York"
python3 $MAPS area "London"

返回邊界框座標、寬度/高度(千米)和近似面積。可用作 bbox 命令的輸入。

bbox — 在邊界框內搜索

python3 $MAPS bbox 40.75 -74.00 40.77 -73.98 restaurant --limit 20

在地理矩形區域內查找 POI。先使用 area 獲取命名地點的邊界框座標。

處理 Telegram 位置標記

當用戶發送位置標記時,消息包含 latitude:longitude: 字段。提取這些字段並直接傳遞給 nearby

# User sent a pin at 36.17, -115.14 and asked "find cafes nearby"
python3 $MAPS nearby 36.17 -115.14 cafe --radius 1500

將結果呈現為帶有名稱、距離和 maps_url 字段的編號列表,以便用戶在聊天中獲得點擊即開的鏈接。對於“現在營業嗎?”之類的問題,檢查 hours 字段;如果缺失或不明確,請使用 web_search 進行驗證,因為 OSM 的營業時間由社區維護,並不總是最新。

工作流示例

“查找羅馬鬥獸場附近的意大利餐廳”:

  1. nearby --near "Colosseum Rome" --category restaurant --radius 500 — 一條命令,自動地理編碼

“他們發送的位置標記附近有什麼?”:

  1. 從 Telegram 消息中提取緯度/經度
  2. nearby LAT LON cafe --radius 1500

“我如何從酒店步行到會議中心?”:

  1. directions "Hotel Name" --to "Conference Center" --mode walking

“西雅圖市中心有哪些餐廳?”:

  1. area "Downtown Seattle" → 獲取邊界框
  2. bbox S W N E restaurant --limit 30

常見陷阱

  • Nominatim 服務條款:最多 1 次請求/秒(由腳本自動處理)
  • nearby 需要緯度/經度或 --near "<address>" — 二者需提供其一
  • OSRM 路徑規劃覆蓋範圍在歐洲和北美最佳
  • Overpass API 在高峰時段可能較慢;腳本會自動在鏡像之間回退(overpass-api.de → overpass.kumi.systems)
  • distancedirections 使用 --to 標誌指定目的地(而非位置參數)
  • 如果僅憑郵政編碼在全球範圍內產生歧義結果,請包含國家/州信息

驗證

python3 ~/.hermes/skills/maps/scripts/maps_client.py search "Statue of Liberty"
# Should return lat ~40.689, lon ~-74.044

python3 ~/.hermes/skills/maps/scripts/maps_client.py nearby --near "Times Square" --category restaurant --limit 3
# Should return a list of restaurants within ~500m of Times Square