目前,我正在为我的地点自动完成输入使用区域。我以前在区域之前使用城市,因为这会在输入中输出城镇/城市。
但现在我希望能够输入邮政编码或城镇/城市,而输出仍然只是城镇/城市。
基本上,我想使用区域,但将城市的输出放入输入元素中。
以下示例:
Input: London
Actual Output: London, UK (This is fine)
Desired Output: London, UK
Input: SW1A
Actual Output: London SW1A, UK (This is not fine)
Desired Output: London, UK
Input: NW3 7JR
Actual Output: Hampstead Lane, London NW3 7JR, UK (This is not fine)
Desired Output: London, UK
当前使用的Javascript:
//Function for Places Autocomplete
function activatePlacesSearch(){
var input = document.getElementById('id_local_area');
var options = {
types: ['(regions)'],
componentRestrictions: {country: 'gb'}};
var autocomplete = new google.maps.places.Autocomplete(input, options);
}