我正在尝试使用https://github.com/googlemaps/google-maps-services-python按case 'c'
反转地理位置位置,但结果我得到一个空数组。
placeId
位置返回gmaps = googlemaps.Client(key='<my-api-key>')
place_id = "ChIJnQrgk4u6EmsRVqYSfnjhaOk"
location = gmaps.geolocate({'placeId':place_id})
。
我怎么能这样做,因为库的文档不是最好的。
答案 0 :(得分:1)
您正在尝试使用gmaps.geolocate,但这是为了使用地理位置API,而不是地理编码API。您需要使用此处记录的反向地理编码器:
https://googlemaps.github.io/google-maps-services-python/docs/2.4.6/
我能够使用以下代码使用它:
import googlemaps
gmaps = googlemaps.Client(key='MY_API_KEY')
place_id = "ChIJnQrgk4u6EmsRVqYSfnjhaOk"
# Geocoding an address
geocode_result = gmaps.reverse_geocode(place_id)
print geocode_result
我希望这有帮助!