#BaiduMap路程计算
def getDistance(deslat,deslng,originlat,originlng):
url='http://api.map.baidu.com/directionlite/v1/driving?origin='+str(originlat)+','+str(originlng)+'&destination='+str(deslat)+','+str(deslng)+'&ak=' #GET请求
ak = '百度密钥'
output = 'json'
url2 = url+ak+'&output='+output
# print(url2)
req = urlopen(url2)
res = req.read().decode()
temp = json.loads(res)
if temp['status']==0 and temp['message']=='ok':
return temp['result']['routes'][0]['distance']
else:
return 0