Reputation: 2720
Simple situation: Marker on map, want to put a DIV next to it that displays on mouse over.
But how on earth do I get the markers current placement for the DIV?
LatLng won't exactly get me anywhere..
Upvotes: 0
Views: 193
Reputation: 3968
This will get position of marker in pixels:
var scale = Math.pow(2, map.getZoom())
, nw = new google.maps.LatLng(
map.getBounds().getNorthEast().lat(),
map.getBounds().getSouthWest().lng()
)
, worldCoordinateNW = map.getProjection().fromLatLngToPoint(nw)
, worldCoordinate = map.getProjection().fromLatLngToPoint(marker.getPosition())
, pixelOffset = new google.maps.Point(
Math.floor((worldCoordinate.x - worldCoordinateNW.x) * scale),
Math.floor((worldCoordinate.y - worldCoordinateNW.y) * scale)
);
Upvotes: 1