Free geolocation via Google's CDN

28 May 2009

Google is now hosting a variety of popular javascript libraries on it's CDN under the name of lovely name of "Google AJAX Library API". The benefits of having Google hosting common code should be clear so I'm not going to babble about it.

What this document does not tell you is that you get free geolocation with it. This fact is hidden in the similarly named "Google AJAX API" (not missing "library"). These are common APIs for Google websites, but lookee here: Client Location (and of 2009-05-29, "New").

Add:


<script src="http://www.google.com/jsapi" type="text/javascript"></script>

And the following is filled out (or is null if they can't figure it out):


  • google.loader.ClientLocation.latitude

  • google.loader.ClientLocation.longitude

  • google.loader.ClientLocation.address.city

  • google.loader.ClientLocation.address.country

  • google.loader.ClientLocation.address.country_code

  • google.loader.ClientLocation.address.region


Comment 2009-05-29 by None

No idea how you find time to blog. I gotta get started on that.