Google API for location, based on user IP address

Ankit picture Ankit · Jul 1, 2013 · Viewed 117.9k times · Source

I am looking for a way to get the user's current location (city) based on is IP address using the Google Maps APIs.

Something similar to http://freegeoip.net/json but only using the Google Maps APIs. Is this possible?

Answer

Peter Knego picture Peter Knego · Jul 1, 2013

Google already appends location data to all requests coming into GAE (see Request Header documentation for go, java, php and python). You should be interested X-AppEngine-Country, X-AppEngine-Region, X-AppEngine-City and X-AppEngine-CityLatLong headers.

An example looks like this:

X-AppEngine-Country:US
X-AppEngine-Region:ca
X-AppEngine-City:norwalk
X-AppEngine-CityLatLong:33.902237,-118.081733