def test_bounds(self): ne = {"lat": 1, "lng": 2} sw = (3, 4) b = {"northeast": ne, "southwest": sw} self.assertEqual("3,4|1,2", convert.bounds(b)) with self.assertRaises(TypeError): convert.bounds("test")
def geocode(client, address=None, components=None, bounds=None, region=None, language=None): 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", [])
def geocode(client, address=None, place_id=None, components=None, bounds=None, region=None, language=None): """ Geocoding is the process of converting addresses (like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. :param address: The address to geocode. :type address: string :param place_id: A textual identifier that uniquely identifies a place, returned from a Places search. :type place_id: string :param components: A component filter for which you wish to obtain a geocode, for example: ``{'administrative_area': 'TX','country': 'US'}`` :type components: dict :param bounds: The bounding box of the viewport within which to bias geocode results more prominently. :type bounds: string or dict with northeast and southwest keys. :param region: The region code, specified as a ccTLD ("top-level domain") 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 place_id: params["place_id"] = place_id 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", [])
def geocode(client, address=None, components=None, bounds=None, region=None, language=None): """ Geocoding is the process of converting addresses (like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. :param address: The address to geocode. :type address: string :param components: A component filter for which you wish to obtain a geocode, for example: ``{'administrative_area': 'TX','country': 'US'}`` :type components: dict :param bounds: The bounding box of the viewport within which to bias geocode results more prominently. :type bounds: string or dict with northeast and southwest keys. :param region: The region code, specified as a ccTLD ("top-level domain") two-character value. :type region: string :param language: The language in which to return results. :type langauge: 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._get("/maps/api/geocode/json", params)["results"]
async def geocode(client, address=None, components=None, bounds=None, region=None, language=None): 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 result = await client._request('/maps/api/geocode/json', params) return result.get('results', [])