从LAT,LNG自定义svg贴图获取X,Y [英] Get X,Y from LAT,LNG custom svg map

查看:132
本文介绍了从LAT,LNG自定义svg贴图获取X,Y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在这里用raphael.js制作地图: http://raphaeljs. com/world/

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

问题是我正在使用自定义的svg世界地图,因此它们的功能getXY()显然不会返回lat,lng的正确x,y.

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.

我如何知道给定纬度/经度的x和y,并知道地图的宽/高以及从一个点及其坐标的融洽关系(x:1104.73 = lng:42.998604)(y:559.25 = lat:9.424553).

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).

他们使用以下代码:

cx: lon * 2.6938 + 465.4

cx: lon * 2.6938 + 465.4

y: lat * -2.6938 + 227.066

y: lat * -2.6938 + 227.066

但是我不知道什么是2.6938和另外两个数字. 我在这里也使用过这种数学方法:

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 x = (int) ((MAP_WIDTH/360.0) * (180 + lon));

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

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

但是我无法使其正常工作,anibody可以帮助我吗?

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

推荐答案

要使用的公式取决于您的地图使用哪种投影(Equirectangular,Robinson,Miller,Lambert,Mercator或其他投影).有关投影的更多信息,请参见 http://en.wikipedia.org/wiki/Map_projection

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

如果您不知道自定义svg世界地图"的投影是什么,您将找不到任何帮助

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

欢呼

这篇关于从LAT,LNG自定义svg贴图获取X,Y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆