Created
December 13, 2009 23:25
-
-
Save juliocesar/255668 to your computer and use it in GitHub Desktop.
Simple Google Ajax LocalSearch example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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