Install
openclaw skills install live-location-mapperSearch Douyin live streams by location, obtain coordinates via Baidu Maps API, and generate static maps marking live stream positions and estimated crowds.
openclaw skills install live-location-mapperVersion: 1.0.0 Price: 1.0 USDT per use
通过抖音直播搜索地点,并在百度地图上标记位置。
用户要求:
需要百度地图 API Key (AK):
使用API获取坐标:
import requests
ak = "你的AK"
# 搜索地点坐标
url = f"https://api.map.baidu.com/place/v2/search?query=外滩®ion=上海&output=json&ak={ak}"
data = requests.get(url).json()
lat = data['results'][0]['location']['lat']
lng = data['results'][0]['location']['lng']
import requests
ak = "你的AK"
locations = [
("主播名(位置)", 经度, 纬度),
("东方明珠", 121.506269, 31.2455),
("南京路步行街", 121.486099, 31.241924),
]
# 生成静态地图
center = f"{lng},{lat}"
markers = "|".join([f"{lng},{lat}" for _,lng,lat in locations])
url = f"https://api.map.baidu.com/staticimage/v2?center={center}&zoom=15&width=800&height=600&markers={markers}&markerStyles=-1,http://api.map.baidu.com/images/marker_red.png,-1,25,25&ak={ak}"
# 下载图片
img = requests.get(url).open('map.png', 'wb').write(img.content)
用户要求查找上海外滩的直播并在地图上标记:
| 地点 | 经度 | 纬度 |
|---|---|---|
| 外滩观景台 | 121.499318 | 31.238549 |
| 东方明珠 | 121.506269 | 31.2455 |
| 南京路步行街 | 121.486099 | 31.241924 |
| 十六铺码头 | 121.50488 | 31.233644 |
| 外白渡桥 | 121.49696 | 31.249557 |