views:

250

answers:

1

What do I need to use to get a search listing using the google maps API?

I can get one address or lat/long but I want to search for say "bars 84070" and get a list of addresses and lat/long.

A: 

You can iterate over the list of results you get back from your search api query:

App.prototype.onSearchComplete = function (sc, searcher) {

    for (var i = 0; i < searcher.results.length; i++)
    {
        var resultLat = searcher.results[i].lat;
        var resultLng = searcher.results[i].lng;
        var point = new GLatLng(resultLat,resultLng);
        var html = results[i].html;

        // do something with the results
    }
}

Update:

According to the Search object documentation if you specify that you want a "large" (google.search.Search.LARGE_RESULTSET) number of results, you will typically get 8 results.

I suggest if you want more local results for an are, you make multiple local search requests for a range of center points and then filter out the duplicates.

Cannonade
nice, how can I control the number of results? Do you know? I want way more.
Phil Wright