'Return an object of this class for a given address by querying the Google
maps geocoding API.
This is intended as a quick convenience function to get fast access to
locations. In the background, this just issues a query to the Google maps
geocoding API. It is not meant to be abused! Google uses IP-based query
limiting and will ban your IP if you send more than a few thousand queries
per hour [1]_.
.. warning::
If the query returns more than one location (e.g., searching on
``address=\'springfield\'``), this function will use the **first** returned
location.
Parameters
address : str
The address to get the location for. As per the Google maps API, this
can be a fully specified street address (e.g., 123 Main St., New York,
NY) or a city name (e.g., Danbury, CT), or etc.
get_height : bool (optional)
Use the retrieved location to perform a second query to the Google maps
elevation API to retrieve the height of the input address [2]_.
Returns
location : This class (a `~astropy.coordinates.EarthLocation` or subclass)
The location of the input address.
References
.. [1] https://developers.google.com/maps/documentation/geocoding/intro
.. [2] https://developers.google.com/maps/documentation/elevation/intro'

@classmethod
def of_address(cls, address, get_height=False):

    pars = urllib.parse.urlencode({'address': address})
    geo_url = 'https://maps.googleapis.com/maps/api/geocode/json?{0}'.format(pars)
    err_str = "Unable    to    retrieve    coordinates    for    address    '{address}';    {{msg}}".format(address=address)
    geo_result = _get_json_result(geo_url, err_str=err_str)
    loc = geo_result[0]['geometry']['location']
    if get_height:
        pars = {'locations': '{lat:.8f},{lng:.8f}'.format(lat=loc['lat'], lng=loc['lng'])}
        pars = urllib.parse.urlencode(pars)
        ele_url = 'https://maps.googleapis.com/maps/api/elevation/json?{0}'.format(pars)
        err_str = "Unable    to    retrieve    elevation    for    address    '{address}';    {{msg}}".format(address=address)
        ele_result = _get_json_result(ele_url, err_str=err_str)
        height = (ele_result[0]['elevation'] * u.meter)
    else:
        height = 0.0
    return cls.from_geodetic(lon=(loc['lng'] * u.degree), lat=(loc['lat'] * u.degree), height=height)
