2
我試過以下代碼從Google Nearby Search獲取地點。谷歌周邊地區的距離
from googleplaces import GooglePlaces, types, lang
YOUR_API_KEY = 'AIzaSyAiFpFd85eMtfbvmVNEYuNds5TEF9FjIPI'
google_places = GooglePlaces(YOUR_API_KEY)
query_result = google_places.query(
location='London, England', keyword='Fish and Chips',
radius=20000, types=[types.TYPE_FOOD])
if query_result.has_attributions:
print query_result.html_attributions
for place in query_result.places:
# Returned places from a query are place summaries.
print place.name
print place.geo_location
print place.reference
# The following method has to make a further API call.
place.get_details()
# Referencing any of the attributes below, prior to making a call to
# get_details() will raise a googleplaces.GooglePlacesAttributeError.
print place.details # A dict matching the JSON response from Google.
print place.local_phone_number
print place.international_phone_number
print place.website
print place.url
我得到了給定位置和半徑的位置列表的JSON輸出。我從json中獲取了名稱,地址,緯度和經度。我也需要那個地方的距離,但無法找到它。有人請幫忙。
三江源的答覆先生。但我看過這個。它需要一個起源和目的地na? – ToothLess
是的。你應該能夠得到你當前的地址。對於目的地,您應該能夠從您的谷歌地點URL中檢索。因此,對於您從Google Place API檢索到的每個結果,都應將其用作destination_address的參數。 – Rudy