From 96039e522def665a9e29a9da088b111defe231d9 Mon Sep 17 00:00:00 2001 From: shaiguelman Date: Sun, 5 Sep 2021 20:49:15 -0700 Subject: [PATCH 1/2] Fixed avoid to allow multiple avoid parameters. --- googlemaps/distance_matrix.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/googlemaps/distance_matrix.py b/googlemaps/distance_matrix.py index a30cbe09..dc18a0b1 100755 --- a/googlemaps/distance_matrix.py +++ b/googlemaps/distance_matrix.py @@ -107,8 +107,12 @@ def distance_matrix(client, origins, destinations, params["language"] = language if avoid: - if avoid not in ["tolls", "highways", "ferries"]: - raise ValueError("Invalid route restriction.") + valid_avoids = ["tolls", "highways", "ferries"] + avoid_tokens = avoid.split("|") + for token in avoid_tokens: + if token not in valid_avoids: + raise ValueError("Invalid route restriction.") + valid_avoids.remove(token) params["avoid"] = avoid if units: From a71dedb522c340c99721ecf1d99bcbfb27f06a4c Mon Sep 17 00:00:00 2001 From: shaiguelman Date: Sun, 5 Sep 2021 21:03:32 -0700 Subject: [PATCH 2/2] Changed documentation to account for change. --- googlemaps/distance_matrix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googlemaps/distance_matrix.py b/googlemaps/distance_matrix.py index dc18a0b1..8742d5c5 100755 --- a/googlemaps/distance_matrix.py +++ b/googlemaps/distance_matrix.py @@ -51,7 +51,8 @@ def distance_matrix(client, origins, destinations, :type language: string :param avoid: Indicates that the calculated route(s) should avoid the - indicated features. Valid values are "tolls", "highways" or "ferries". + indicated features. Valid values are "tolls", "highways" or "ferries" + as well as any combination of them separated by "|". :type avoid: string :param units: Specifies the unit system to use when displaying results.