【发布时间】:2023-04-08 09:34:02
【问题描述】:
我正在为我的标记添加一个事件监听器,标记的功能是:
function setupMarkerWaypoint(){
console.log('setting waypoint marker');
waypointMarker = new google.maps.Marker({
position: default_latlng,
map: mapBooking,
icon:"http://maps.google.com/mapfiles/ms/micons/blue.png"
});
waypointMarker.setVisible(true);
function geocodePosition(pos) {
geocoder.geocode({
'latLng': pos
}, function(responses) {
if (responses && responses.length > 0) {
updateMarkerAddress(responses[0].formatted_address);
} else {
updateMarkerAddress('Cannot determine address at this location.');
}
});
}
function updateMarkerAddress(str) {
document.getElementById('AddWaypoint').innerHTML = str;
}
// Update current position info.
geocodePosition(latLng);
// Add dragging event listeners.
google.maps.event.addListener(waypointMarker, 'dragend', function() {
updateMarkerStatus('Drag ended');
geocodePosition(waypointMarker.getPosition());
});
}
但我无法在谷歌地图上拖动我的标记。我应该做哪些必要的改变?
【问题讨论】:
标签: javascript google-maps google-maps-api-3 google-maps-markers dom-events