\GeoMashupGeonamesGeocoder

HTTP geocoder using the geonames web services.

Includes an additional method for looking up administrative area names.

Summary

Methods
Properties
Constants
__construct()
geocode()
reverse_geocode()
get_administrative_name()
$request_params
$language
$max_results
No constants found
url_utf8_encode()
$http
N/A
No private methods found
$geonames_username
N/A

Properties

$request_params

$request_params : array

Parameters to use with http requests.

Type

array

$language

$language : string

Language code.

Type

string

$max_results

$max_results : integer

Maximum number of results

Type

integer

$http

$http : float

WP_Http instance

Type

float

$geonames_username

$geonames_username : string

The application username to include in geonames API requests.

Type

string

Methods

__construct()

__construct( $args)

Constructor

Parameters

$args

geocode()

geocode( $query) : array|\WP_Error

Look up locations from a text query, like an address or place name.

Parameters

$query

Returns

array|\WP_Error —

Array of search result locations.

reverse_geocode()

reverse_geocode( $lat,  $lng) : array|\WP_Error

Look up additional location information from coordinates.

Resulting locations have as much address information as possible filled in. Most services return the nearest match first, and some return only one.

Parameters

$lat
$lng

Returns

array|\WP_Error —

Array of search result locations.

get_administrative_name()

get_administrative_name(string $country_code, string $admin_code) : string|\WP_Error

Use the Geonames web service to look up an administrative name.

Parameters

string $country_code
string $admin_code

Admin area name to look up. If empty, look up the country name.

Returns

string|\WP_Error —

The administrative name.

url_utf8_encode()

url_utf8_encode( $text) : string

Convert a text term to UTF-8 if necessary before URL encoding.

Parameters

$text

Returns

string —

Encoded text.