NotACat
NotACat

Reputation: 11

google maps find_place() positional arguments problem

I need to use the googlemaps/google-maps-services-python for a project, and there is the problem.

I want to use find_place():

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

But when I launch my script

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)

there is a problem:


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)

If I do

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

it works but I get no result (because input is not there anymore).

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

There is a confusion between the positional arguments, as if there was a hidden argument ... what happens?

Upvotes: 0

Views: 1307

Answers (1)

Damini Ganesh
Damini Ganesh

Reputation: 308

Won't it work if you do

loca = place.gmaps.find_place(client=place.key,input="place to find", input_type="textquery",fields=['place_id','formatted_address'])

Upvotes: 2

Related Questions