How to use the googlemaps.convert.components 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
self.assertEqual("country:US", convert.components(c))

        c = {"country": "US", "foo": 1}
        self.assertEqual("country:US|foo:1", convert.components(c))

        c = {"country": ["US", "AU"], "foo": 1}
        self.assertEqual("country:AU|country:US|foo:1", convert.components(c))

        with self.assertRaises(TypeError):
            convert.components("test")

        with self.assertRaises(TypeError):
            convert.components(1)

        with self.assertRaises(TypeError):
            convert.components(("c", "b"))
github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_components(self):
        c = {"country": "US"}
        self.assertEqual("country:US", convert.components(c))

        c = {"country": "US", "foo": 1}
        self.assertEqual("country:US|foo:1", convert.components(c))

        c = {"country": ["US", "AU"], "foo": 1}
        self.assertEqual("country:AU|country:US|foo:1", convert.components(c))

        with self.assertRaises(TypeError):
            convert.components("test")

        with self.assertRaises(TypeError):
            convert.components(1)

        with self.assertRaises(TypeError):
            convert.components(("c", "b"))
github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_components(self):
        c = {"country": "US"}
        self.assertEqual("country:US", convert.components(c))

        c = {"country": "US", "foo": 1}
        self.assertEqual("country:US|foo:1", convert.components(c))

        c = {"country": ["US", "AU"], "foo": 1}
        self.assertEqual("country:AU|country:US|foo:1", convert.components(c))

        with self.assertRaises(TypeError):
            convert.components("test")

        with self.assertRaises(TypeError):
            convert.components(1)

        with self.assertRaises(TypeError):
            convert.components(("c", "b"))
github googlemaps / google-maps-services-python / test / test_convert.py View on Github external
def test_components(self):
        c = {"country": "US"}
        self.assertEqual("country:US", convert.components(c))

        c = {"country": "US", "foo": 1}
        self.assertEqual("country:US|foo:1", convert.components(c))

        c = {"country": ["US", "AU"], "foo": 1}
        self.assertEqual("country:AU|country:US|foo:1", convert.components(c))

        with self.assertRaises(TypeError):
            convert.components("test")

        with self.assertRaises(TypeError):
            convert.components(1)

        with self.assertRaises(TypeError):
            convert.components(("c", "b"))
github googlemaps / google-maps-services-python / googlemaps / geocoding.py View on Github external
two-character value.
    :type region: string

    :param language: The language in which to return results.
    :type language: string

    :rtype: list of geocoding results.
    """

    params = {}

    if address:
        params["address"] = address

    if components:
        params["components"] = convert.components(components)

    if bounds:
        params["bounds"] = convert.bounds(bounds)

    if region:
        params["region"] = region

    if language:
        params["language"] = language

    return client._request("/maps/api/geocode/json", params).get("results", [])
github hzlmn / aiogmaps / aiogmaps / places.py View on Github external
strict_bounds=False):

    params = {'input': input_text}

    if offset:
        params['offset'] = offset
    if location:
        params['location'] = convert.latlng(location)
    if radius:
        params['radius'] = radius
    if language:
        params['language'] = language
    if types:
        params['types'] = types
    if components:
        params['components'] = convert.components(components)
    if strict_bounds:
        params['strictbounds'] = 'true'

    url = '/maps/api/place/%sautocomplete/json' % url_part
    result = await client._request(url, params)
    return result['predictions']
github googlemaps / google-maps-services-python / googlemaps / places.py View on Github external
if session_token:
        params["sessiontoken"] = session_token
    if offset:
        params["offset"] = offset
    if location:
        params["location"] = convert.latlng(location)
    if radius:
        params["radius"] = radius
    if language:
        params["language"] = language
    if types:
        params["types"] = types
    if components:
        if len(components) != 1 or list(components.keys())[0] != "country":
            raise ValueError("Only country components are supported")
        params["components"] = convert.components(components)
    if strict_bounds:
        params["strictbounds"] = "true"

    url = "/maps/api/place/%sautocomplete/json" % url_part
    return client._request(url, params).get("predictions", [])