【发布时间】:2019-08-02 08:52:19
【问题描述】:
我正在创建一个应用程序,允许用户指定地理位置数据,然后将其作为节点渲染到矢量墨卡托投影矢量图像上。
所以我购买了以下墨卡托投影矢量图像: https://www.vectorstock.com/royalty-free-vector/world-map-gray-mercator-projection-lasercut-vector-23277786
我从以下文章中找到了将地理位置数据转换为像素的公式: Convert latitude/longitude point to a pixels (x,y) on mercator projection
但是,转换不正确,我认为它与我使用的图像有关,它不是示例中使用的“普通”墨卡托地图(85 度)。
因此,我的问题是:有没有办法通过提供的图像实现我想要的?如果是的话,我想要一些关于下面提供的代码的帮助。如果没有,如果您可以提供一个与所提供的具有相同风格的图片(矢量,免费或出售)的网址,我真的很感激。
非常感谢!
public mapWidth: number = 2476;
public mapHeight: number = 1607;
public node: NodeLocation = { latitude: 8.161366, longitute: 77.454603, x: null, y: null };
public render() {
let latitudeToRadians = ((this.node.latitude * Math.PI) / 180);
let mercN = Math.log(Math.tan((Math.PI / 4) + (latitudeToRadians / 2)));
this.node.x = ((this.node.longitute + 180) * (this.mapWidth / 360));
this.node.y = ((this.mapHeight / 2) - ((this.mapWidth * mercN) / (2 * Math.PI)));
}
【问题讨论】:
标签: typescript geolocation 2d map-projections mercator