Google local search API - callback never called
Posted
by Laurent Luce
on Stack Overflow
See other posts from Stack Overflow
or by Laurent Luce
Published on 2010-05-02T19:42:38Z
Indexed on
2010/05/02
19:47 UTC
Read the original article
Hit count: 240
Hello,
I am trying to retrieve some local restaurants using the LocalSearch Google API. I am initializing the search objects in the OnLoad function and I am calling the searchControl execute function when the user clicks on a search button.
The problem is that my function attached to setSearchCompleteCallback never get called.
Please let me know what I am doing wrong here.
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('maps' , '2');
google.load('search' , '1');
var searcher, searchControl;
function OnLoad() {
searchControl = new google.search.SearchControl();
searcher = new google.search.LocalSearch(); // create the object
// Add the searcher to the SearchControl
searchControl.addSearcher(searcher);
searchControl.setSearchCompleteCallback(searcher , function() {
var results = searcher.results; // Grab the results array
// We loop through to get the points
for (var i = 0; i < results.length; i++) {
var result = results[i];
}
});
$('#user_search_address').live('click', function() {
g_searchControl.execute('pizza san francisco');
});
}
google.setOnLoadCallback(OnLoad);
</script>
© Stack Overflow or respective owner