From 994ca869df2ef3e493438fc114c26f20266ddcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Foucault?= Date: Mon, 4 Jun 2018 12:21:28 +0200 Subject: [PATCH 1/2] feat: Add strictbounds param --- googleplaces/__init__.py | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/googleplaces/__init__.py b/googleplaces/__init__.py index 9508444..c9a1ada 100644 --- a/googleplaces/__init__.py +++ b/googleplaces/__init__.py @@ -354,7 +354,7 @@ def text_search(self, query=None, language=lang.ENGLISH, lat_lng=None, return GooglePlacesSearchResult(self, places_response) def autocomplete(self, input, lat_lng=None, location=None, radius=3200, - language=lang.ENGLISH, types=None, components=[]): + language=lang.ENGLISH, types=None, components=[], strictbounds=None): """ Perform an autocomplete search using the Google Places API. @@ -362,31 +362,36 @@ def autocomplete(self, input, lat_lng=None, location=None, radius=3200, are optional. keyword arguments: - input -- The text string on which to search, for example: - "Hattie B's". - lat_lng -- A dict containing the following keys: lat, lng - (default None) - location -- A human readable location, e.g 'London, England' - (default None) - radius -- The radius (in meters) around the location to which the - search is to be restricted. The maximum is 50000 meters. - (default 3200) - language -- The language code, indicating in which language the - results should be returned, if possible. (default lang.ENGLISH) - types -- A type to search against. See `types.py` "autocomplete types" - for complete list - https://developers.google.com/places/documentation/autocomplete#place_types. - components -- An optional grouping of places to which you would - like to restrict your results. An array containing one or - more tuples of: - * country: matches a country name or a two letter ISO 3166-1 country code. - eg: [('country','US')] + input -- The text string on which to search, for example: + "Hattie B's". + lat_lng -- A dict containing the following keys: lat, lng + (default None) + location -- A human readable location, e.g 'London, England' + (default None) + radius -- The radius (in meters) around the location to which the + search is to be restricted. The maximum is 50000 meters. + (default 3200) + strictbounds -- Returns only those places that are strictly within the region defined by + location and radius. This is a restriction, rather than a bias, meaning that + results outside this region will not be returned even if they match the user input + language -- The language code, indicating in which language the + results should be returned, if possible. (default lang.ENGLISH) + types -- A type to search against. See `types.py` "autocomplete types" + for complete list + https://developers.google.com/places/documentation/autocomplete#place_types. + components -- An optional grouping of places to which you would + like to restrict your results. An array containing one or + more tuples of: + * country: matches a country name or a two letter ISO 3166-1 country code. + eg: [('country','US')] """ self._request_params = {'input': input} if lat_lng is not None or location is not None: lat_lng_str = self._generate_lat_lng_string(lat_lng, location) self._request_params['location'] = lat_lng_str self._request_params['radius'] = radius + if strictbounds: + self._request_params['strictbounds'] = 'true' if types: self._request_params['types'] = types if len(components) > 0: From 65ba61fe4b6a3fe723431cdedb1f62dccea2b145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Foucault?= Date: Mon, 4 Jun 2018 12:25:57 +0200 Subject: [PATCH 2/2] doc: Update readme --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index ab3699d..fdc408a 100644 --- a/README.rst +++ b/README.rst @@ -201,6 +201,10 @@ Reference search is to be restricted. The maximum is 50000 meters. (default 3200) + strictbounds -- Returns only those places that are strictly within the region defined by + location and radius. This is a restriction, rather than a bias, meaning that + results outside this region will not be returned even if they match the user input + language -- The language code, indicating in which language the results should be returned, if possible. (default lang.ENGLISH)