附近24小时药店
生成药店和门诊信息列表要生成药店和门诊信息列表,需要从相关数据源中获取信息。可以考虑使用 Google Places API 或其他本地搜索工具来获取附近的位置信息。获取位置信息使用 Google Places API 获取附近药店和门诊的位置信息:import googlemaps设置你的 Google Places API 密钥
api_key = "YOUR_API_KEY"创建 GoogleMaps 客户端
client = googlemaps.Client(api_key)执行搜索请求
results = client.places_nearby(location="YOUR_LOCATION", 替换为你的位置radius=5000, 搜索半径为 5 公里type="pharmacy", 搜索药店类型open_now=True, 仅返回目前营业的地点
)解析结果
for place in results["results"]:print(place["name"]) 打印药店名称print(place["place_id"]) 打印药店 Place ID使用类似的方法获取附近门诊的位置信息,将 "type" 参数替换为 "hospital" 或 "clinic"。格式化信息列表获取位置信息后,可以将它们格式化为 HTML 列表:
html
嵌入地图要嵌入地图,可以使用 Google Maps Embed API:
html
<iframe src="https://maps.google.com/maps?q=<?php echo implode(" ,",="" $locations);="" ?="">&output=embed"width="100%"height="500px"frameBorder="0">
其中 `$locations` 是要在地图上显示的药店和门诊的纬度经度字符串。