4

Is it possible to determine the pixel co-ordinates of a given marker, taking into account current zoom level and visible area of the map?

Jonathan
  • 32,202
  • 38
  • 137
  • 208

1 Answers1

5

Current (v3):

map.getProjection().fromLatLngToPoint(marker.position);

https://developers.google.com/maps/documentation/javascript/3.exp/reference#Projection

Old (v2):

The method fromLatLngToContainerPixel following should give you what you're after, assuming markerPoint is your marker, and zoomLevel your current zoom:

map.fromLatLngToContainerPixel(markerPoint.getLatLng(), zoomLevel);
Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
ConroyP
  • 40,958
  • 16
  • 80
  • 86
  • 1
    Thanks, that's just the method I needed! (Actually it would be: 'map.fromLatLngToContainerPixel(markerPoint.getLatLng(), zoomLevel);' as the first parameter should be a GLatLng object.) – Jonathan Oct 12 '09 at 07:33
  • Updated to reflect markerPoint comment, and added direct link to documentation. – ConroyP Oct 12 '09 at 09:05
  • 5
    V3 does not support this method. – Nazmul Apr 28 '11 at 02:33