Having taken the example page for Map Coordinates as a starting point -
http://code.google.com/apis/maps/documentation/javascript/examples/map-coordinates.html

... I tried to do a the conversion shown here in reverse.
Obviously, I have some problems.

Here is my pseudo code -
1. Convert pixels to world coordinates
    x = pixel x / pow(2, zoom level)
    y = pixel y / pow(2, zoom level)

2. Convert world coordinates to lat/lng
    Lng = (x – pixel origin x) / Pixels per Longitude in degrees
    Lat = rad2deg(2 * atan(exp(latRadians)) – pi / 2)
    where latRadians =
    (y – pixel orgin y) / Pixels per Longitude in radians

Using the output values from the example page :
Pixel X : 67247
Pixel Y : 97459
Zoom Level : 10

I get the following results
Latitude : 97459
Longitude : 67247

These are conversions I need to do on the server.
Can anyone help me correcting the formulas ?

Simon

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to