我有这个代码:'dragend'事件的函数()中的代码没有执行,文档中的 latFld 和 llgFld 没有更新任何帮助?
var map;
var marker;
function initMap()
{
var latlng = new google.maps.LatLng(-27.780577, -64.279906);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, "click", function(event) {
if (marker) {marker.setMap(null)}
marker = new google.maps.Marker({
position: event.latLng,
map: map,
draggable:true
});
// display the lat/lng in your form's lat/lng fields
document.getElementById("latFld").value = event.latLng.lat();
document.getElementById("lngFld").value = event.latLng.lng();
});
google.maps.event.addListener(marker, 'dragend', function(){
alert(marker.getPosition());
document.getElementById("latFld").value = marker.getPosition().lat();
document.getElementById("lngFld").value = marker.getPosition().lng();
});
}