Hidden Google Feature Shows User Location

Adam DuVander
Jul. 27 2009, 12:08AM EDT

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

Adam DuVander Hi! I'm Developer Communications Director for SendGrid and former Executive Editor of ProgrammableWeb. I currently serve as a Contributing Editor. If you have API news, or are interested in writing for ProgrammableWeb, please contact editor@programmableweb.com Though I'm a fan of anything API-related, my particular interest is in mapping. I've published a how-to book, Map Scripting 101, to get anyone started making maps on websites. In a not-so-distant past life I wrote for Wired and Webmonkey.

Comments

Comments(4)

User HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Hmmm...good to know. Certainly a good headline :) gotta think about what this means.