计算距离矩阵时googlemaps.exceptions.TransportError

时间:2019-04-27 16:58:01

标签: python-2.7 google-maps flask google-api

问题:TransportError:HTTPSConnectionPool(host ='maps.googleapis.com',port = 443):URL超过了最大重试次数:/maps/api/distancematrix/json?destinations=17.445134%2C78.349222&mode=walking&origins=17.44882 %2C78.344386&key = AIzaSyD9JkQXx1V6_Z9XUUcIXsUlYHpeCst3AcI(由SSLError(SSLError(1,u'[SSL:WRONG_VERSION_NUMBER]错误的版本号(_ssl.c:726)'),)))

gmaps = googlemaps.Client(key = 'XYZ') 


query = "SELECT * FROM ridedetails WHERE (sourcecity LIKE '%" + City + "%' and sourcepincode = '"+ pincode +"') and ridetime = '" + rideTime + "'"
  df = pd.read_sql(query, g.db)
  distancelist = []
  for index in range(len(df)):
    if session['userid'] == df.iloc[[index]]['userid'].iloc[0]:
      continue
    LatOrigin = df.iloc[[index]]['sourcelat'] 
    LongOrigin = df.iloc[[index]]['sourcelong']
    origins = (LatOrigin,LongOrigin)
    userorigin = (sourceLat, sourceLong)
    result = gmaps.distance_matrix(origins, userorigin, mode='walking')["rows"][0]["elements"][0]["distance"]["value"]
    distancelist.append(result)
  print(distancelist) 
  return distancelist

我想使用人的纬度/经度来计算一个人到另一个人的距离。

但是无法使用此api做到这一点。

0 个答案:

没有答案