I'm posting this here so that if anyone else stumbles across it, it is
documented.

An easy way to get the distance (in pixels) between two coordinates on
a Google map is to simply calculate it  with no map API at all:

x = ((RADIANS(lng)/PI()+1)/2) * POWER(2, zoom_level) * 256
y = (1-((LN(TAN(PI()/4 + RADIANS(lat)/2)))/PI()/2+0.5)) * POWER(2,
zoom_level) * 256

This gives you the position (x and y) in pixels from the top left
corner of the entire virtual map at zoom level "zoom_level" for a
coordinate at latitude "lat" and longitude "lng".  The functions
RADIANS, POWER, LN, and TAN are LibreOffice functions; substitute
equivalent functions in your own language.

Now that I look at it, I can see ways to simplify, but I don't feel
like doing that now.  Feel free to respond with a simpler function.

--
Tim Koop

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to