Hi,
I'm looking for a method (in Java / javascript or other languages) to
convert lat / long coordinates to the absolute X/Y coordinates for a
given zoom.
By absolute X/Y coordinates I am NOT talking about screen pixel
coordinates that would be used if I wanted to position a marker on the
map.
By absolute X/Y coordinates I am talking about the X/Y coordinates
within the overall map at a given zoom level.
For example, knowing that at zoom level 1 the world is 256 * 2exp1
(=512) pixels wide and high, the absolute pixel coordinate of the
equator and general meridian intersection would be X= 256 and Y =
256.
I have this old method but I think it was meant to be used with the
old zooming system (when zoom levels were descending).
public static Point getPixelCoordinatesAtZoom(double latitude, double
longitude ,int zoom){
double exp = Math.sin(latitude*Math.PI/180);
if (exp < -.9999) {
exp = -.9999;
}
if (exp > .9999) {
exp = .9999;
}
int y = (int)Math.round(
(256 <<(zoom-1)) +
(.5 * Math.log((1+exp)/(1-exp))) *
(
(-256<<zoom) / (2*Math.PI)
)
);
int x = (int)Math.round(
(256 << (zoom-1)) +
(
longitude * ((256 << zoom )/ 360)
)
);
Point p = new Point(x,y);
return p;
}
So can someone give me some pointers on how to calculate this
accurately ?
Thanks in Advance.
I hope I am clear enough :)
If not let me know
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---