Python googlemaps 库和 Google 地点之间的差异 API 与 Postman 的通话
Discrepancy between Python googlemaps library and Google Places API call with Postman
当我通过此 GET 调用从 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 库是什么?
我自己找到了解决方案,我会post为像我一样挣扎的人提供答案:
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)
当我通过此 GET 调用从 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 库是什么?
我自己找到了解决方案,我会post为像我一样挣扎的人提供答案:
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)