Hi. A simple AutocompleteService request.
And running this script (sorry, tried to do a JSBin
http://jsbin.com/sujatuzaro/edit?html,js,output but it won't load the API)
function runQuery(country) {
var request = {
input: 'london',
componentRestrictions: {country: country},
};
var callback = function(predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
var resultsString = predictions.reduce(function (prev, current) {
return prev + "\n" + current.description;
}, "RESULTS FOR " + country + "\n--------------\n");
console.log(resultsString);
};
var service = new window.google.maps.places.AutocompleteService();
service.getQueryPredictions(request, callback);
}
function onAPILoaded() {
runQuery('uk');
runQuery('ca');
}
RESULTS FOR uk
--------------
London, United Kingdom
London, ON, Canada
London Borough of Hillingdon, United Kingdom
London Eye, London, United Kingdom
London Bridge, London, United Kingdom
RESULTS FOR ca
--------------
London, United Kingdom
London, ON, Canada
London Borough of Hillingdon, United Kingdom
London Eye, London, United Kingdom
London Bridge, London, United Kingdom
RESULTS FOR uk
--------------
London, United Kingdom
London, ON, Canada
London Borough of Hillingdon, United Kingdom
London Eye, London, United Kingdom
London Bridge, London, United Kingdom
....
The problem is not that they are repeated a few times (although that is odd) but the fact the componentRestrictions doesn't seem to have any effect.
Any idea? Thanks in advance.