I want m开发者_Go百科y application using Google local search and google maps to give my users the ability to choose from a number of locations when there are a number of possible answers to their query. A good example would be "Overton, UK" - there are lots of places with this name in the country, and the google maps website gives several possible "did you mean results".
The API, however, doesn't give you this information. Both localsearch and GClientGeocoder return one result.
Is there a way to get the API to return a list of possible results?
Have you tried using geocode
from google.maps.Geocoder()
(version 3 of the Maps API)? I'm pretty sure that it returns an array of results:
var geocoder = new google.maps.Geocoder();
if(geocoder) {
geocoder.geocode({address: address}, function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
//do stuff with results, which is an array of address results
}
else {
//error handling
}
});
}
else {
//error handling
}
More information at Maps API V3 Services. The page goes into detail about the structure of the address results object.
精彩评论