有没有办法让Google地方自动填充仅限于法国这样的国家?
我有这个:components=country:fr
https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places&language=fr&components=country:fr&key=API_KEY
但这并没有限制自动完成。
答案 0 :(得分:2)
此代码适用于我。
var input = document.getElementById('city_field');
var options = {
types: ['(cities)'],
componentRestrictions: {country: countryCode},
language: "en"
};
autocomplete = new google.maps.places.Autocomplete(input, options);
仔细检查参数名称components = country:fr syntax