-1

Hi to all i'm developing a map with raphael.js as they do in here : http://raphaeljs.com/world/

the problem is that i'm using a custom svg world map so they function getXY() obviously wont return the correct x,y of a lat,lng.

How can i calculate the x and y of a given lat/lng knowing the map width/height and the rapport froma point and his coordinates (x:1104.73=lng:42.998604)(y:559.25=lat:9.424553).

they use this code:

cx: lon * 2.6938 + 465.4

y: lat * -2.6938 + 227.066

but i cant figure out what is 2.6938 and the other two numbers. I've also used this math here:

int x = (int) ((MAP_WIDTH/360.0) * (180 + lon));

int y = (int) ((MAP_HEIGHT/180.0) * (90 - lat));

But i cant get it works,anibody can help me?

Dtnand
  • 449
  • 3
  • 14

1 Answers1

0

The formula to use depends on what projection (Equirectangular, Robinson, Miller, Lambert, Mercator, or other one) is used by your map. More on projections here http://en.wikipedia.org/wiki/Map_projection

You will not find any help if you don't know what is the projection for your "custom svg world map"

Cheers

phron
  • 1,795
  • 17
  • 23
  • The projection is a Mercator, but anyway i discovered that there is no way yo do that. So i started using D3 and topojson with provide u correct maps sizes etc. Thanks for the answer – Dtnand Jan 08 '14 at 12:09
  • @Dtnand can you tell me how you do it ?? – Ashok Mandal Jul 14 '18 at 05:59