Google AJAX Loader and ClientLocation via IP

The AJAX APIs from Google brings some cool new features for Javascript developers.

With the AJAX Libraries API the “load”-method of the “google”-object can now load some common Javascript-frameworks which are hostet on Google-servers. For example jQuery or jQuery UI, Dojo, YUI or SWFObject. After including the main javascript file you can use the google object, when finished, a callback-function will be called.

[sourcecode language=”html”]


There is also a new and very important property at the google.loader object, if “ClientLocation” is not null then Google have found the location of the current user by IP-address. ClientLocation have a latitude, longitude and address property. If you wanna see it in action look at the example on

[sourcecode language=”javascript”]

if (google.loader.ClientLocation) {

// dynamic loading with callback
google.load(“maps”, “2”, {“callback” : function(){
var map = new google.maps.Map2(document.getElementById(“bhc-map”));
map.setCenter(new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude), 11);



As you can see above, really simple to create a map from the current position and now we can show the user some local news from …

[sourcecode language=”javascript”]

google.load(“search”, “1”, {“callback” : function(){

// only code fragment … see example for full code
var search = new;



Mashup example: Use ClientLocation with Map and Search API.

  • Mike

    Any idea on how to add weather overlay to the map?


  • hugo peterson

    google.loader.clientlocation.address is null or not an object Help me to solve this Error please, Thank You!!!

  • hugo peterson

    An error has occurred in the scrip on this page