Javascript 移动地图时获取地址
当dragend映射时,我无法获取地址(但如果dragend标记,则工作) JSFIDLEJavascript 移动地图时获取地址,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,当dragend映射时,我无法获取地址(但如果dragend标记,则工作) JSFIDLE 您需要在地图拖动中传递坐标以获得地址,就像此事件不包含latlng一样 geocoder.geocode({ 'latLng': this.center }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { var
您需要在地图拖动中传递坐标以获得地址,就像此事件不包含latlng一样
geocoder.geocode({
'latLng': this.center
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var alamat = results[0].formatted_address;
document.getElementById("alamat").value = alamat;
// alert(alamat);
}
}
});
看到了吗效果很好。。谢谢我可以为中心地图的搜索地址添加输入type=“text”吗?@Edofx没有得到您可以解释吗?选中搜索框中的fiddle,可以键入地址,如果找到,以地址为中心的地图。您的意思是从地址和中心地图获得坐标是正确的吗?检查我的脚本,可能是错误的。未定义控制台locateAddress处的get错误。出什么事了?
geocoder.geocode({
'latLng': this.center
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var alamat = results[0].formatted_address;
document.getElementById("alamat").value = alamat;
// alert(alamat);
}
}
});