我正在使用Python Google地图包装器(http://py-googlemaps.sourceforge.net/)并尝试获取一些行车路线。我在纬度/经度对中有大量测试位置,这是我通过在Google地图上对某些地址进行地理编码而获得的。但是,在运行我的程序时,我收到Google Maps错误602,我认为这意味着它无法找到与该纬度和经度相关联的地址。这是抛出错误时运行的函数:
def GetDirections(loc1, loc2):
origin = gmaps.latlng_to_address(loc1.lat, loc1.lng)
destination = gmaps.latlng_to_address(loc2.lat, loc2.lng)
return gmaps.directions(origin, destination)
这是我得到的错误:
File "allocationtesting.py", line 69, in GetDistance
return GetDirections(loc1, loc2)['Directions']
File "allocationtesting.py", line 84, in GetDirections
return gmaps.directions(origin, destination)
File "googlemaps.py", line 450, in directions
raise GoogleMapsError(status_code, url=url, response=response)
googlemaps.GoogleMapsError: Error 602: G_GEO_UNKNOWN_ADDRESS
...所以,奇怪的是地址正在被解析(即latlng_to_address()函数没有错误)但是在找到两个位置之间的方向时会抛出错误602。这两个地点都在英国的主要城市,所以我看不出这是怎么回事。我已经尝试过再次对测试地址进行地理编码,它提供了与我在测试数据中相同的纬度和经度对。有谁知道什么可能是错的?我以前从未遇到过这个问题。