0
好了,我已經建立了一個工作(幾乎)地理編碼器,它接受一個地址或經/緯度組合,並建議成果在這裏看到:地理編碼返回ZERO_RESULT和QUERY_LIMIT_REACHED
$(this).autocomplete({
source:function (request, response) {
if (geocoder == null) {
geocoder = new google.maps.Geocoder();
}
geocoder.geocode({'address':request.term }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var searchLoc = results[0].geometry.location;
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
var latlng = new google.maps.LatLng(lat, lng);
var bounds = results[0].geometry.bounds;
geocoder.geocode({'latLng':latlng}, function (results1, status1) {
if (status1 == google.maps.GeocoderStatus.OK) {
if (results1[1]) {
response($.map(results1, function (loc) {
return {
label:loc.formatted_address,
lat:lat,
lng:lng,
value:loc.formatted_address,
bounds:loc.geometry.bounds
}
}));
}
}
});
}
});
},
和90%的它的工作時間非常有效。但是,我現在注意到,偶爾會在彈出式列表中返回的第一個項目不可點擊。我已經爲變量status
設置了日誌,並且注意到偶爾會出現ZERO_RESULT
或QUERY_LIMIT_REACHED
。在這兩種情況下,列表都會加載值,列表中的所有內容都是可選的,但第一種情況除外。任何想法可能的解決方案?