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
。在这两种情况下,列表都会加载值,列表中的所有内容都是可选的,但第一种情况除外。任何想法可能的解决方案?