【发布时间】:2013-01-19 20:25:15
【问题描述】:
所以,我使用的是谷歌的反向地理编码器,所以我最初做的是输入一个地址,例如东京,然后我得到那个 latlng 将 latlng 放回地理编码器中以接收正确的位置名称但是相反,它只是返回未定义。我的代码是:
var geocoder = new google.maps.Geocoder();
var place = document.getElementById("location").value;
var name;
var place_latlng;
geocoder.geocode({'address' : place}, function(results, status){
if (status == google.maps.GeocoderStatus.OK){
place_latlng = results[0].geometry.location;
addMarker(place_latlng);
}
});
geocoder.geocode({'latLng' : place_latlng},function(results, status){
if (status == google.maps.GeocoderStatus.OK){
name = results[0].formatted_address;
}
});
name 每次都未定义,有什么办法可以解决这个问题吗?
【问题讨论】:
标签: javascript html google-maps-api-3 google-geocoder