简体   繁体   中英

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)?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM