javascript 传单中经纬度的坐标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31842608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:26:56  来源:igfitidea点击:

Coordinates to Lat Long in Leaflet

javascriptcoordinatesleaflet

提问by Templeton Peck

I'm here because I'm trying to create a GTA V map with Leafletjs API. In deed, I've got my tiles that are ready. But the aim is to put markers on the map by using GTA V in-game coordinates. To achieve it, I need to convert the coordinates to LatLong but after many researches, I can't find a solution.

我来这里是因为我正在尝试使用 Leafletjs API 创建 GTA V 地图。事实上,我的瓷砖已经准备好了。但目的是通过使用 GTA V 游戏内坐标在地图上放置标记。为了实现它,我需要将坐标转换为 LatLong 但经过多次研究,我找不到解决方案。

Example : enter image description hereThanks in advance.

示例: 在此处输入图片说明提前致谢。

回答by Hinrich

Your coordinates are coming from different map projections. The Leaflet ones are most probably standard WGS 84 (SRID 4326). GTA V coordinates are obviously based on a different projection.

您的坐标来自不同的地图投影。Leaflet 最有可能是标准的 WGS 84 (SRID 4326)。GTA V 坐标显然基于不同的投影。

Coordinates can be transformed from one projection to anothers. But you need to know, which projection your coordinates are coming from, to do the math. Hereis an online converter provided with some common projections, and i tried your coordinates, but had no luck in coming close with these projections.

坐标可以从一种投影转换为另一种投影。但是您需要知道您的坐标来自哪个投影,以进行数学计算。 是一个提供一些常见投影的在线转换器,我尝试了您的坐标,但没有运气接近这些投影。

回答by artem_p

I tried this:

我试过这个:

var latlng = new L.latLng(-43.1731, 6.6906);
var point = L.Projection.Mercator.project(latlng);
console.log(point);
// o.Point {x: 744794.1851014761, y: -5309112.129212381}

It is not close to your GTA V coordinates, but I'm not sure it were just for example.

它与您的 GTA V 坐标并不接近,但我不确定它是否只是举例。

回答by Fo.

You can use L.latlngfunction

您可以使用L.latlng功能

http://leafletjs.com/reference.html#latlng

http://leafletjs.com/reference.html#latlng