当我通过此GET调用使用Postman从Google Places API检索JSON代码时:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?types=movie_theater&location=-36.8485,174.763336&radius=10000&key=PutYourAPIKeyHere
我看到"types"
之后有"vicinity"
;然后方括号闭合并为下一项业务再次打开:
但是如果我使用官方的Google Maps Python library来检索相同的呼叫,则:
import googlemaps
gmaps = googlemaps.Client(key='PutYourAPIKeyHere')
search_loction = gmaps.places("nearby",location='-36.8485, 174.763336', type="movie_theater")
print (search_loction)
我发现在"types"
之后没有"vicinity"
,括号就好像是该业务的最后一个要素一样在关闭吗?
在Postman API调用中,我传递了nearbysearch
,而在Python中,我传递了nearby
。
nearbysearch
和nearby
一样吗?
如果不是,那么附近对googlemaps库的搜索是什么?
答案 0 :(得分:-2)
我自己找到了解决方案,我将为那些像我一样挣扎的人提供答案:
import googlemaps
gmaps = googlemaps.Client(key='PutYourAPIKeyHere')
search_loction = gmaps.places_nearby(location='-36.8485, 174.763336', type="movie_theater",radius="10000")
#print (search_loction)
Total_Places_Found = 0
if search_loction['status'] == 'OK':
Total_Places_Found += len(search_loction['results'])
for element in search_loction['results']:
Place_ID = element['place_id']
ID = element['id']
Name = element['name']
Latitude = element['geometry']['location']['lat']
Longitude = element['geometry']['location']['lng']
Rating = element['rating']
Types = element['types']
vicinity = element['vicinity']
print (vicinity)