Код: Выделить всё
import googlemaps
gmaps = googlemaps.Client(key='')
origin = 'New York, NY' #zero result if replaced it with shinjuku station, tokyo
destination = 'Los Angeles, CA' #zero result if replaced it with harajuku station,tokyo
result = gmaps.distance_matrix(origin, destination, mode='transit',region="jp")
if result['rows']:
element = result['rows'][0]['elements'][0]
print(f"Distance: {element['distance']['text']}, Duration: {element['duration']['text']}")
< /code>
Я попытался использовать Place AutoComplete < /p>
def autocomplete_place(input_text):
result = gmaps.places_autocomplete(input_text)
if result:
return result[0]['description']
return None
def get_departure_time() -> datetime:
"""Get departure time at 8 AM Tokyo time"""
tokyo_tz = pytz.timezone('Asia/Tokyo')
return datetime.now(tokyo_tz).replace(hour=8, minute=0, second=0, microsecond=0)
< /code>
Но все же возвращает пустой результат. Тем не менее, как только я использую нас города, это работает отлично. На стороне примечание. «Вождение» и «ходьба» режим путешествия тоже работает
Подробнее здесь: https://stackoverflow.com/questions/793 ... r-japan-ci