Convert Lat/Longs to X/Y Co-ordinates

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2009-06-19T20:56:37Z Indexed on 2010/05/26 10:11 UTC
Read the original article Hit count: 209

Filed under:
|
|

I have the Lat/Long value of New York City, NY; 40.7560540,-73.9869510 and a flat image of the earth, 1000px × 446px.

I would like to be able to convert, using Javascript, the Lat/Long to an X,Y coordinate where the point would reflect the location.

So the X,Y coordinate form the Top-Left corner of the image would be; 289, 111

Things to note:

  1. don't worry about issues of what projection to use, make your own assumption or go with what you know might work
  2. X,Y can be form any corner of the image
  3. Bonus points for the same solution in PHP (but I really need the JS)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about maps