I am using google map v3 api. I need to detect the drag event on the map. Be it the drag on the map to move to a nearby geographical location or a drag on the marker. I need some javascript function to run when either of the events occur.
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'); } );