What is the best way to calculate the pixel distance between to coordinates (lat/lon) in a Google Map. I am not asking about the distance in km/miles (therefore I have a library), but pixels on the screen considering the current zoom factor.
Background: I want to draw overlays without overlapping them. So I need to calculate the offset for these positions. So in a lower zoom factor a distance of 500 km can mean the overlays do overlap, while at 50km they don't.
Of course, any other algorithm to avoid overlaps not based on the pixel distance would be appreciated.
-- Update --
Guess is is going in the direction of clustering, will check this:
- http://www.appelsiini.net/2008/11/introduction-to-marker-clustering-with-google-maps
- http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/advanced_example.html
-- Update --
Most likely I can use this here: http://code.google.com/apis/maps/documentation/javascript/reference.html
google.maps.MapCanvasProjection.fromLatLngToDivPixel
To get the projection I will use the answers here: