How to use the googlemaps.convert.join_list function in googlemaps

To help you get started, we’ve selected a few googlemaps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_join_list(self):
        self.assertEqual("asdf", convert.join_list("|", "asdf"))

        self.assertEqual("1,2,A", convert.join_list(",", ["1", "2", "A"]))

        self.assertEqual("", convert.join_list(",", []))

        self.assertEqual("a,B", convert.join_list(",", ("a", "B")))
github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_join_list(self):
        self.assertEqual("asdf", convert.join_list("|", "asdf"))

        self.assertEqual("1,2,A", convert.join_list(",", ["1", "2", "A"]))

        self.assertEqual("", convert.join_list(",", []))

        self.assertEqual("a,B", convert.join_list(",", ("a", "B")))
github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_join_list(self):
        self.assertEqual("asdf", convert.join_list("|", "asdf"))

        self.assertEqual("1,2,A", convert.join_list(",", ["1", "2", "A"]))

        self.assertEqual("", convert.join_list(",", []))

        self.assertEqual("a,B", convert.join_list(",", ("a", "B")))
github googlemaps / google-maps-services-python / googlemaps / places.py View on Github external
:rtype: result dict with the following keys:
        result: dict containing place details
        html_attributions: set of attributions which must be displayed
    """
    params = {"placeid": place_id}

    if fields:
        invalid_fields = set(fields) - PLACES_DETAIL_FIELDS
        if invalid_fields:
            raise ValueError(
                "Valid values for the `fields` param for "
                "`place` are '%s', these given field(s) "
                "are invalid: '%s'"
                % ("', '".join(PLACES_DETAIL_FIELDS), "', '".join(invalid_fields))
            )
        params["fields"] = convert.join_list(",", fields)

    if language:
        params["language"] = language
    if session_token:
        params["sessiontoken"] = session_token

    return client._request("/maps/api/place/details/json", params)
github googlemaps / google-maps-services-python / googlemaps / distance_matrix.py View on Github external
if units:
        params["units"] = units

    if departure_time:
        params["departure_time"] = convert.time(departure_time)

    if arrival_time:
        params["arrival_time"] = convert.time(arrival_time)

    if departure_time and arrival_time:
        raise ValueError("Should not specify both departure_time and"
                         "arrival_time.")

    if transit_mode:
        params["transit_mode"] = convert.join_list("|", transit_mode)

    if transit_routing_preference:
        params["transit_routing_preference"] = transit_routing_preference

    if traffic_model:
        params["traffic_model"] = traffic_model

    if region:
        params["region"] = region

    return client._request("/maps/api/distancematrix/json", params)
github googlemaps / google-maps-services-python / googlemaps / places.py View on Github external
"""

    params = {"minprice": min_price, "maxprice": max_price}

    if query:
        params["query"] = query
    if location:
        params["location"] = convert.latlng(location)
    if radius:
        params["radius"] = radius
    if keyword:
        params["keyword"] = keyword
    if language:
        params["language"] = language
    if name:
        params["name"] = convert.join_list(" ", name)
    if open_now:
        params["opennow"] = "true"
    if rank_by:
        params["rankby"] = rank_by
    if type:
        params["type"] = type
    if region:
        params["region"] = region
    if page_token:
        params["pagetoken"] = page_token

    url = "/maps/api/place/%ssearch/json" % url_part
    return client._request(url, params)
github googlemaps / google-maps-services-python / googlemaps / geocoding.py View on Github external
:rtype: list of reverse geocoding results.
    """

    # Check if latlng param is a place_id string.
    #  place_id strings do not contain commas; latlng strings do.
    if convert.is_string(latlng) and ',' not in latlng:
        params = {"place_id": latlng}
    else:
        params = {"latlng": convert.latlng(latlng)}

    if result_type:
        params["result_type"] = convert.join_list("|", result_type)

    if location_type:
        params["location_type"] = convert.join_list("|", location_type)

    if language:
        params["language"] = language

    return client._request("/maps/api/geocode/json", params).get("results", [])
github googlemaps / google-maps-services-python / googlemaps / directions.py View on Github external
if region:
        params["region"] = region

    if departure_time:
        params["departure_time"] = convert.time(departure_time)

    if arrival_time:
        params["arrival_time"] = convert.time(arrival_time)

    if departure_time and arrival_time:
        raise ValueError("Should not specify both departure_time and"
                         "arrival_time.")

    if transit_mode:
        params["transit_mode"] = convert.join_list("|", transit_mode)

    if transit_routing_preference:
        params["transit_routing_preference"] = transit_routing_preference

    if traffic_model:
        params["traffic_model"] = traffic_model

    return client._request("/maps/api/directions/json", params).get("routes", [])
github googlemaps / google-maps-services-python / googlemaps / geocoding.py View on Github external
:param language: The language in which to return results.
    :type language: string

    :rtype: list of reverse geocoding results.
    """

    # Check if latlng param is a place_id string.
    #  place_id strings do not contain commas; latlng strings do.
    if convert.is_string(latlng) and ',' not in latlng:
        params = {"place_id": latlng}
    else:
        params = {"latlng": convert.latlng(latlng)}

    if result_type:
        params["result_type"] = convert.join_list("|", result_type)

    if location_type:
        params["location_type"] = convert.join_list("|", location_type)

    if language:
        params["language"] = language

    return client._request("/maps/api/geocode/json", params).get("results", [])