Skip to content

Commit b963ff9

Browse files
authored
fix: Add parameter 'origin' to places autocomplete (#392)
1 parent 6d2ee96 commit b963ff9

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

googlemaps/places.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def places_autocomplete(
501501
input_text,
502502
session_token=None,
503503
offset=None,
504+
origin=None,
504505
location=None,
505506
radius=None,
506507
language=None,
@@ -525,6 +526,12 @@ def places_autocomplete(
525526
service will match on 'Goo'.
526527
:type offset: int
527528
529+
:param origin: The origin point from which to calculate straight-line distance
530+
to the destination (returned as distance_meters).
531+
If this value is omitted, straight-line distance will
532+
not be returned.
533+
:type origin: string, dict, list, or tuple
534+
528535
:param location: The latitude/longitude value for which you wish to obtain the
529536
closest, human-readable address.
530537
:type location: string, dict, list, or tuple
@@ -558,6 +565,7 @@ def places_autocomplete(
558565
input_text,
559566
session_token=session_token,
560567
offset=offset,
568+
origin=origin,
561569
location=location,
562570
radius=radius,
563571
language=language,
@@ -611,6 +619,7 @@ def _autocomplete(
611619
input_text,
612620
session_token=None,
613621
offset=None,
622+
origin=None,
614623
location=None,
615624
radius=None,
616625
language=None,
@@ -629,6 +638,8 @@ def _autocomplete(
629638
params["sessiontoken"] = session_token
630639
if offset:
631640
params["offset"] = offset
641+
if origin:
642+
params["origin"] = convert.latlng(origin)
632643
if location:
633644
params["location"] = convert.latlng(location)
634645
if radius:

tests/test_places.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def test_autocomplete(self):
212212
"Google",
213213
session_token=session_token,
214214
offset=3,
215+
origin=self.location,
215216
location=self.location,
216217
radius=self.radius,
217218
language=self.language,
@@ -223,6 +224,7 @@ def test_autocomplete(self):
223224
self.assertEqual(1, len(responses.calls))
224225
self.assertURLEqual(
225226
"%s?components=country%%3Aau&input=Google&language=en-AU&"
227+
"origin=-33.86746%%2C151.20709&"
226228
"location=-33.86746%%2C151.20709&offset=3&radius=100&"
227229
"strictbounds=true&types=geocode&key=%s&sessiontoken=%s"
228230
% (url, self.key, session_token),

0 commit comments

Comments
 (0)