我正在创建一个应用程序,允许用户指定地理位置数据,然后将其作为节点渲染到矢量墨卡托投影矢量图像上。
所以我买了以下墨卡托投影矢量图像: https ://www.vectorstock.com/royalty-free-vector/world-map-gray-mercator-projection-lasercut-vector-23277786
我从以下文章中找到了将地理位置数据转换为像素的公式: 将纬度/经度点转换为墨卡托投影上的像素 (x,y)
但是,转换不正确,我认为它与我使用的图像有关,而不是像示例中使用的那样的“普通”墨卡托地图(85 度)。
因此,我的问题是:有没有办法通过提供的图像实现我想要的?如果是的话,我想对下面提供的代码有所帮助。如果没有,如果您可以提供一个与所提供的具有相同风格的图像(矢量、免费或出售)的 URL,我真的会很高兴。
非常感谢!
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)));
}