Google Map Api v3 drag event on map
Both Map objects and Marker objects have drag
events, although you probably want dragend
so that you can do something when a user is done dragging rather than do something while a user is dragging.
So you could do something like this:
google.maps.event.addListener(map, 'dragend', function() { alert('map dragged'); } );
google.maps.event.addListener(marker, 'dragend', function() { alert('marker dragged'); } );
google.maps.event.addListener(map, "mouseover", function (e) {
google.maps.event.addListener(map, "dragend", function () {
setTimeout(() => {
console.log(e); // this contains the information about the coordinates
});
});
});