您必须在 _geocode 函数中过滤结果,您在结果对象中迭代才能找到 type=="country" & shortname==your country code,并且您只选择满足此条件的那个
这是我为法国地址修改的函数,它有点脏,但它可以工作
// Autocomplete source method: fill its suggests with google geocoder results
_geocode: function(request, response) {
var address = request.term, self = this;
this.geocoder.geocode({
'address': address + this.options.appendAddressString,
'region': this.options.regionBias
}, function(results, status) {
var fr_results= [];
if (status == google.maps.GeocoderStatus.OK) {
for (var i = 0; i < results.length; i++) {
results[i].label = results[i].formatted_address;
for (var j = 0; j<results[i].address_components.length; j++)
{
//console.log(results[i]);
if ((results[i].address_components[j].types[0] =="country") && (results[i].address_components[j].short_name =="FR"))
{
//console.log(results[i].address_components[j].short_name);
results[i].label = results[i].formatted_address;
//fr_results[i] = results[i];
fr_results.push(results[i]);
}
}
};
}
//console.log(results);
//console.log(fr_results);
response(fr_results);
})
},
如果有人有最好的方法,我会接受:)
高频dg