这是我的例外:
这是我的javascript:
var geocoder;
var map;
function codeAddress() {
var address = document.getElementById("address").value;
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//console.log(results);
//console.log("Lat: " + results[0].geometry.location.coords.latitude);
//console.log("Lng: " + results[0].geometry.location.coords.longitude);
return results[0].geometry.location;
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
所以有一个results
并且它被填充,但它没有拉长。
我用于测试的地址是: 1600 Amphitheatre Parkway,Mountain View,CA 基于https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRequests,但这不仅仅是针对此地址。
我真的不知道。它几乎是示例代码的精确副本。
编辑 jsFiddle http://jsfiddle.net/7tvv71hs/