私はこのコードを持っています: 'dragend' イベントの function() のコードが実行されず、ドキュメントの 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();
});
}