Esa's Google Maps API examples

Dragging a marker

'Mousemove' event is used to update markers position when 'mousedown' is present. 'Mouseup' stops the updating.

Problem with FF is that it does not give 'mousemove' when the left button of mouse is pressed. Right button works better but it opens menu when released. Center button opens a new tab. IE works fine this time.

A latitude offset between mouse and marker position must be calculated for different zoom settings.

The offset in this study is calculated by Math.pow(2,(4 - map.getZoom())).

addDomListener v2.39+

'Mouseup' GEvent is available on marker only. It was added on map using GEvent.addDomListener() which makes it possible to use GEvents on DOM blocks. In this case on the "map" <div>. That listener is for safety. Now 'mouseup' event will be fired even when the offset between mouse and marker is wrong.