#
hs.location.geocoder
Converts between GPS coordinates and more user friendly representations like an address or points of interest.
This module converts between GPS coordinates and the user-friendly representation of that coordinate. A user-friendly representation of the coordinate typically consists of the street, city, state, and country information corresponding to the given location, but it may also contain a relevant point of interest, landmarks, or other identifying information.
Your computer must have network access for the geocoder object to return detailed placemark information and is rate limited. Geocoding requests are rate-limited, so making too many requests in a short period of time may cause some of the requests to fail with a network error.
Use of this module does not require Location Services to be enabled for Hammerspoon.
A placemarkTable
is returned to the callback functions used by the constructor methods of this module. These tables may contain one or more of the following keys:
addressDictionary
- a table containing key-value pairs for the components of the address for the placemarkadministrativeArea
- a string containing the state or province associated with the placemarksubAdministrativeArea
- a string containing additional administrative area information for the placemarkareasOfInterest
- a table as an array of strings describing areas of interest associated with the placemarkcountry
- a string containing the name of the country associated with the placemarkcountryCode
- a string containing the standard abbreviation for the country associated with the placemarkinlandWater
- a string containing the name of the inland water body associated with the placemarklocality
- a string containing the city associated with the placemarksubLocality
- a string containing additional city-level information for the placemarklocation
- the locationTable, as described in thehs.location
module header, for the placemarkname
- a string containing the name of the placemarkocean
- a string containing the name of the ocean associated with the placemarkpostalCode
- a string containing the postal code associated with the placemarkregion
- a regionTable, as described in thehs.location
module header, specifying the he geographic region associated with the placemarkthoroughfare
- a string containing the street address associated with the placemarksubThoroughfare
- a string containing additional street-level information for the placemarktimeZone
- a string containing the time zone associated with the placemark
#
API Overview
Constructors - API calls which return an object, typically one that offers API methods
lookupAddress lookupAddressNear lookupLocation
Methods - API calls which can only be made on an object returned by a constructor
cancel geocoding
#
API Documentation
#
Constructors
#
lookupAddress
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.location.geocoder.lookupAddress(address, fn) -> geocoderObject
|
| Type | Constructor |
| Description | Look up geocoding information for the specified address. |
| Parameters |
address
- a string containing address information as commonly expressed in your locale.fn
- A callback function which should expect 2 arguments and return none:state
- a boolean indicating whether or not geocoding data was providedresult
- ifstate
is true indicating that geocoding was successful, this argument will be a table containing one or more placemarkTables (as described in the module header) containing the geocoding data available for the location. Ifstate
is false, this argument will be a string containing an error message describing the problem encountered.
- a geocodingObject
- This constructor requires internet access and the callback will be invoked with an error message if the internet is not currently accessible.
- This constructor does not require Location Services to be enabled for Hammerspoon.
#
lookupAddressNear
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.location.geocoder.lookupAddressNear(address, [regionTable], fn) -> geocoderObject
|
| Type | Constructor |
| Description | Look up geocoding information for the specified address. |
| Parameters |
address
- a string containing address information as commonly expressed in your locale.regionTable
- an optional regionTable as described in thehs.location
header used to prioritize the order of the results found. If this parameter is not provided and Location Services is enabled for Hammerspoon, a region containing current location is used.fn
- A callback function which should expect 2 arguments and return none:state
- a boolean indicating whether or not geocoding data was providedresult
- ifstate
is true indicating that geocoding was successful, this argument will be a table containing one or more placemarkTables (as described in the module header) containing the geocoding data available for the location. Ifstate
is false, this argument will be a string containing an error message describing the problem encountered.
- a geocodingObject
- This constructor requires internet access and the callback will be invoked with an error message if the internet is not currently accessible.
- This constructor does not require Location Services to be enabled for Hammerspoon.
- While a partial address can be given, the more information you provide, the more likely the results will be useful. The
regionTable
only determines sort order if multiple entries are returned, it does not constrain the search.
#
lookupLocation
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.location.geocoder.lookupLocation(locationTable, fn) -> geocoderObject
|
| Type | Constructor |
| Description | Look up geocoding information for the specified location. |
| Parameters |
locationTable
- a locationTable as described in thehs.location
header specifying a location to obtain geocoding information about.fn
- A callback function which should expect 2 arguments and return none:state
- a boolean indicating whether or not geocoding data was providedresult
- ifstate
is true indicating that geocoding was successful, this argument will be a table containing one or more placemarkTables (as described in the module header) containing the geocoding data available for the location. Ifstate
is false, this argument will be a string containing an error message describing the problem encountered.
- a geocodingObject
- This constructor requires internet access and the callback will be invoked with an error message if the internet is not currently accessible.
- This constructor does not require Location Services to be enabled for Hammerspoon.