Question

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?

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top