Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting location from coordinates?

Tags:

php

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

like image 779
iamandrus Avatar asked Dec 16 '22 16:12

iamandrus


2 Answers

Check out Google Maps' Reverse Geocoding API.

like image 94
Haochi Avatar answered Dec 19 '22 05:12

Haochi


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.

like image 33
Abhinav Avatar answered Dec 19 '22 06:12

Abhinav