Google Maps find_place () проблема позиционных аргументов - PullRequest
0 голосов
/ 25 апреля 2019

Мне нужно использовать googlemaps / google-maps-services-python для проекта, и здесь есть проблема.

Я хочу использовать find_place ():

def find_place(client, input, input_type, fields=None, location_bias=None,
                language=None):

Но когда я запускаю свой скрипт

import googlemaps
from datetime import datetime


class Place:

    def __init__(self, words):
        self.words = words
        self.key = 'Key'
        self.gmaps = googlemaps.Client(key=self.key)


place = Place(['place to find'])
print(place.key)
loca = place.gmaps.find_place(self.key,"place to find","textquery",['place_id','formatted_address'])
print(loca)

, возникает проблема:


Traceback (most recent call last):
  File "gpbapp/program/place.py", line 15, in <module>
    loca = place.gmaps.find_place(place.key,place.words[0],"textquery",['place_id','formatted_address'])
  File "C:\Users\krfou\Documents\OPENCLASSROOMS\p7\env\lib\site-packages\googlemaps\client.py", line 365, in wrapper
    result = func(*args, **kwargs)
  File "C:\Users\krfou\Documents\OPENCLASSROOMS\p7\env\lib\site-packages\googlemaps\places.py", line 94, in find_place
    "the given value is invalid: '%s'" % input_type)
ValueError: Valid values for the `input_type` param for `find_place` are 'textquery' or 'phonenumber', the given value is invalid: 'disneyland, paris'
(env)

Если я делаю

loca = place.gmaps.find_place(place.key,"textquery",['place_id','formatted_address'])

, это работает, но я не получаю результата (потому что ввода больше нет).

{'candidates': [], 'status': 'ZERO_RESULTS'}

Между позиционными аргументами возникает путаница, как будтобыл скрытый аргумент ... что происходит?

1 Ответ

2 голосов
/ 25 апреля 2019

Разве это не сработает, если вы сделаете

loca = place.gmaps.find_place(client=place.key,input="place to find", input_type="textquery",fields=['place_id','formatted_address'])
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...