高德地图开发指南的一些调用api文档在这个网址
https://lbs.amap.com/api/webservice/guide/api/newpoisearch
周边搜索 API 服务地址(get请求)
https://restapi.amap.com/v5/place/around?parameters
地理编码 API 服务地址(get请求)
htmlhttps://restapi.amap.com/v3/geocode/geo?parameters
步行路径规划API URL(get请求)
https://restapi.amap.com/v3/direction/walking?parameters
骑行路径规划API URL(get请求)
https://restapi.amap.com/v4/direction/bicycling?parameters
代码如下
import requests
import json
def current_location(key, address):
# 获取当前位置的经纬度
info = requests.get("https://restapi.amap.com/v3/geocode/geo?parameters",
params={
"key": "3fbf8b85af364be7acbf51b22a81b04e",
"address": address})
# 使用get方法调用api,同时传入key和address参数(见文档)
dict = json.loads(info.text)
# json.loads()是用来读取字符串的,即可以把文件打开,用readline()读取一行,然后json.loads()一行
# json.load()也可用来读取文件的,即将文件打开然后就可以直接读取
# print(dict["geocodes"][0]["location"]) 查看一下位置信息
return (dict["geocodes"][0]["location"]) # 返回位置信息
def destination_info(key, address, keywords, radius):
# 获取目的场所周围poi及poi的经纬度
info = requests.get("https://restapi.amap.com/v3/place/around?parameters",
params={
"key":"3fbf8b85af364be7acbf51b22a81b04e",
"location": current_location(key, address),
"keywords": keywords,
"radius": radius})
# 使用get方法调用api,同时传入key,location(当前位置),keywords(目的场所关键字),radisu参数(见文档)
dict = json.loads(info.text)
# 由于目的地关键字