I'm having problems telling the Google maps API to restrict the results from the geocoding service to a specific region.
A simple example reproducing the problem is here: http://jsfiddle.net/pqZGr/
The JavaScript code is really simple:
$(document).ready(function () {
var geocoder = new google.maps.Geocoder();
$("#name").autocomplete({
source: function (request, response) {
geocoder.geocode({ 'address': request.term, 'region': 'it' }, function (results, status) {
response($.map(results, function (item) {
return {
value: item.formatted_address
}
}));
})
}
});
});
I also specified the API URL as http://maps.google.com/maps/api/js?region=it&language=it&sensor=false
besides the 'region': 'it'
in the request.
The problem is the addresses returned by Google are not restricted (nor hinted) to Italy
For example if you search mil
(the begininning of Milano
) I get Circondario di Miltenberg, Germania
and Milion, Alemdar Mh., 34122 Istanbul/Provincia di Istanbul, Turchia
and reka Mil', Sacha-Jacuzia, Russia
.
It's returning results (also, only three?) from all over the world, an nothing from Italy (even when there are multiple cities matching mil
).
What am I doing wrong?
As a side note, is it possible to restrict the search only to the cities, and not to full addresses?
Thanks in advance.