geoPlugin Home

Webservice Extras

The geoPlugin webservice extras build on the base webservices and are always being added to, based on your ideas and requests.
If you have any request for a webservice extras, please let us know and we'll do what we can to incorporate it.

Latitude/Longitude to Place

Not only can geoPlugin provide you with geolocation of IP addresses, but we can also reverse geocode any given latitude and longitude coordinates to a place.
This reverse geocoding allows you to specify the latitude and longitude coordinates and will output the nearest populated place in PHP, JSON, or XML formats.

To reverse geocode a latitude/longitude coordinate pair, simply call:

http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY


replace XXX and YYY with the latitude and longitude values, respectively.

If no populated place is found within a 10-mile radius of your given coordinates, the server will return null



The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:



For PHP:

http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY&format=php

For JSON:

http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY&format=json

For XML:

http://www.geoplugin.net/extras/location.gp?lat=XXX&long=YYY&format=xml



The location of 38/-97 (you) is:

	 Place: Potwin
Country Code: US
Region: Kansas
Latitude: 37.9719009
Longitude: -97.0006027
Distance (miles): 1.94
Distance (km): 3.12


Nearby Places

Rather than give you the exact nearest populated place to a set of latitude/logitude coordinates, geoPlugin can reverse geocode latitude and longitude values to provide you with any number of populated places nearby.

As with the base webservices, with the exception of Javascript (use JSON for that), places nearby can be output in PHP, JSON, or XML to suite your needs.

To find places nearby a geographical location, simply call:

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY


replace XXX and YYY with the latitude and longitude values, respectively.

If no latitude or longitude values are set, then the lat/long values from PHP's $_SERVER['REMOTE_ADDR'] will be used, which may not be desirable



You can specify how many results to return by tagging on the limit variable eg

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY&limit=10

to return a maximum of 10 results


Additionally, you can specify the radius (in miles) of the search for nearby places, by tagging on the radius variable eg

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY&limit=10&radius=50

to return all nearby populated places within 50 miles of the given point.




The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:



For PHP:

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY&format=php

For JSON:

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY&format=json

For XML:

http://www.geoplugin.net/extras/nearby.gp?lat=XXX&long=YYY&format=xml




For PHP users, the PHP Class has nearby places all built in.



Nearby places to you include:

1:
Place: Potwin
Region: Kansas
County: Butler
Latitude: 37.9719009
Longitude: -97.0006027
Distance (miles): 1.94
Distance (km): 3.12
Direction (degrees) 178.82
Direction (heading) S
2:
Place: Whitewater
Region: Kansas
County: Butler
Latitude: 37.9612007
Longitude: -97.1307983
Distance (miles): 7.61
Distance (km): 12.25
Direction (degrees) 106.09
Direction (heading) ESE
3:
Place: Elbing
Region: Kansas
County: Butler
Latitude: 38.0545006
Longitude: -97.1284027
Distance (miles): 7.94
Distance (km): 12.78
Direction (degrees) 64.69
Direction (heading) ENE
4:
Place: Burns
Region: Kansas
County: Marion
Latitude: 38.1222000
Longitude: -96.8634033
Distance (miles): 11.25
Distance (km): 18.1
Direction (degrees) 44.94
Direction (heading) NE




Latitude/Longitude to Postal Code

The reverse geocoding of a latitude/longitude coordinate pair to populated place given above uses a database of many millions of geospatial coordinates and is very well developed, especially for developed countries.

However, because of copyright and cost issues, we cannot provide postal codes (zip codes) for all of these places.

Nonetheless, we can provide reverse geocoding of latitude/longitude coordinate pairs to postal codes for about a million of these locations.

This post code web service can be accessed using:

http://www.geoplugin.net/extras/postalcode.gp?lat=XXX&long=YYY


To provide the nearest populated place with a post code within a 10-mile radius of your given coordinates.

Like always, the format= variable can be appended to specify PHP, JSON, or XML outputs.

The closest place with a post code we have on file for 38/-97 (you) is:

	 Place: Potwin
Country Code: US
Post Code: 67123
Latitude: 37.9719009
Longitude: -97.0006027
Distance (miles): 1.94
Distance (km): 3.12
Confidence: 0




See also