问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/20820406/get-x-y-from-lat-lng-custom-svg-map