0
function initMap() {
var this_input;
/* var options = {
types: ['(cities)'],
componentRestrictions: {country: "my"}
};*/
$("input[name=location]").focusin(function(){
// alert($(this).attr("id"));
this_input = $(this).attr("id");
var input = /** @type {!HTMLInputElement} */(
document.getElementById(this_input));
var autocomplete = new google.maps.places.Autocomplete(input);
var infowindow = new google.maps.InfoWindow();
var geocoder = new google.maps.Geocoder();
autocomplete.addListener('place_changed', function() {
infowindow.close();
var place = autocomplete.getPlace();
if (!place.geometry) {
window.alert("Autocomplete's returned place contains no geometry");
return;
}
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
});
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder);
});
});//end of input[name=location]
}
以上是我的腳本,顯示任何focusin
文本框與name ='location'
的自動完成。這工作正常。就是這樣,我已經刪除了一堆geocoder
代碼,它提醒輸入位置的狀態,即:ZERO_RESULTS。如何防止Google的地理編碼警報狀態訊息?
但它不斷提醒,QUERY OVER LIMIT,ZERO_RESULT消息。我不知道這些消息是從哪裏提示的,因此我該如何解決這個問題?
請提供一個[最小,完整,已測試和可讀的示例](http://stackoverflow.com/help/mcve)來說明問題。 – geocodezip