Courchevel, Saint-Bon-Tarentaise, France
出現在結果中,但是當我想使用此地址時geocode
無法識別它。Google api autocomplete無法識別地址
它只承認這一個Courchevel 1650, Saint-Bon-Tarentaise, France
。
我該如何使原始地址可被識別?
var placeSearch, autocomplete, destination;
var componentForm = {
street_number: 'short_name',
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name',
postal_code: 'short_name'
};
function initAutocomplete() {
// Create the autocomplete object, restricting the search to geographical
// location types.
autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */
(document.getElementById('from')), {
types: ['geocode']
}
);
// When the user selects an address from the dropdown, populate the address
// fields in the form.
autocomplete.addListener('place_changed', fillInAddress);
destination = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */
(document.getElementById('to')), {
types: ['geocode']
}
);
// When the user selects an address from the dropdown, populate the address
// fields in the form.
destination.addListener('place_changed', fillInAddressDestination);
}
// [START region_fillform]
function fillInAddress() {
var place = autocomplete.getPlace();
for (var component in componentForm) {
document.getElementById(component).value = '';
document.getElementById(component).disabled = false;
}
// Get each component of the address from the place details
// and fill the corresponding field on the form.
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[addressType]) {
var val = place.address_components[i][componentForm[addressType]];
document.getElementById(addressType).value = val;
}
}
}
// [END region_fillform]