iamandrus
iamandrus

Reputation: 1430

Getting location from coordinates?

I have a script to get a user's coordinates when they go to a certain page, but I need a way to get their approximate location (city, state, country, etc.). Is there a way I go about doing this server-side (preferrably PHP)?

Upvotes: 4

Views: 4363

Answers (3)

Abhinav
Abhinav

Reputation: 39884

Choices that I have found till now

  1. Google Maps reverse geocoding API
  2. Yahoo Geoplanet API
  3. SimpleGeo
  4. Geonames.org
  5. Bing reverse geocoding API

All of these expose simple HTTP endpoints for retrieving the address depending on a particular lat/lng combination.

You can also download the geonames database and use PostGIS or MySQL's spatial extension to build your own service. Advantage is that you won't have to worry about rate limits. Disadvantage is that it won't be very accurate.

SimpleGeo does not have any rate limits but the database is limited to the US the last time I checked.

Upvotes: 3

whoughton
whoughton

Reputation: 1385

Assuming you are getting lat/long coordinates, then you could use something like SimpleGeo's services: http://simplegeo.com/

I think the Google option is better, SimpleGeo sounds like way more than you need.

Upvotes: 0

HChen
HChen

Reputation: 2141

Check out Google Maps' Reverse Geocoding API.

Upvotes: 9

Related Questions