Hidden Google Feature Shows User Location

You may already have access to your user's location and not know it yet. If you use Google's Ajax API loader to access Maps, Search or Feeds, you're one line of JavaScript away from knowing the user's country, city, or even a nearby latitude/longitude point.

The code is described at the bottom of the documentation, almost as an afterthought. However, there is a complete description of the ClientLocation object that contains the data and an example.

It is perhaps easier to use than the 3 IP geolocation methods I described in a previous post. Though, this is a JavaScript-only API, meaning it cannot be accessed server-side.

If you're worried about sharing your location, privacy should not be more of a concern than usual. Google's service, like those mentioned in the earlier post, uses your computer's IP address. The series of four numbers (like is publicly available and usually can only pin-point you at city-level accuracy.

That said, as with other geolocation services there's certainly some funny stuff possible, but I'm sure you'll use it for good, right? Right?

Hat tip: Brian Cray

Be sure to read the next Mapping article: Mapify a MediaWiki with New Extension