marker snippets

How to find a Google Map marker's exact position

Tagged google-maps, marker, position, relative  Languages javascript

You need a custom OverlayWindow:

function ProjectionHelperOverlay(map) {

ProjectionHelperOverlay.prototype = new google.maps.OverlayView();
ProjectionHelperOverlay.prototype.draw = function () {
  if (!this.ready) {
    this.ready = true;
    google.maps.event.trigger(this, 'ready');

overlay = new ProjectionHelperOverlay(map);

And you need to find the markers position relative to the overlay:

google.maps.event.addListener(marker, 'mouseover', function(event) {
  var p = overlay.get_projection().fromLatLngToDivPixel(marker.get_position());

  // map world relative to map container
  var container = overlay.get_panes().mapPane.parentNode;
  var x = p.x + parseInt(;
  var y = p.y + parseInt(;

Code found in this thread on Google Groups.