Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created December 13, 2009 23:25
Show Gist options
  • Save juliocesar/255668 to your computer and use it in GitHub Desktop.
Save juliocesar/255668 to your computer and use it in GitHub Desktop.
Simple Google Ajax LocalSearch example
// Run the code below after you loaded the API with your key, though a separate file
// or straight onto the body of the document.
(function() {
google.load('search', '1');
function loaded() {
window.localsearch = new google.search.LocalSearch();
};
google.setOnLoadCallback(loaded);
})();
// Check via a console (you're on Firefox + Firebug/Safari/Chrome right?), like so:
//
// localsearch.execute('Cabana Bar Sydney')
//
// The above will return a results object you can iterate through.
// Also, it seems to be important that the scope where you run google.load should be
// [object Window]. Anywhere else I tried, it would sit there loading something
// indefinitely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment