javascript - OpenLayers LonLat 转换不在正确的投影范围内

标签 javascript google-maps openlayers gis

我的 map 使用 EPSG:900013 投影。结果,在获取鼠标位置时,我得到的值以米为单位,范围为 -20037508.342789244 到 20037508.342789244。

我使用了 LonLat 类的 .transform() 方法,使用 EPSG:900913 作为源投影,并且(没有考虑)使用 EPSG:4329 作为目标投影。

我的问题是,为什么 EPSG:4329 给我的范围是 -180、180、-80.05、85.05(我想要的)而不是 -180、180、-90、90(它应该给我的,因为这些是正确的界限 http://spatialreference.org/ref/epsg/wgs-84/ )?

最佳答案

我相对确定您的源投影 (900913) 正在设置这些限制,因此当您移动鼠标时,您只能移动距离 0,0 这么多米,这对应于 85.05 和 -80.05在你的转变中。

换句话说,EPSG 900913 并不涵盖整个地球。因此,当您分别将鼠标移动到最远的北/南时,它不会转换为 +/- 90,而是转换为 85.05 和 -80.05,如您所见。

如果你去检查this page in the OpenLayers docs ,他们解释如下:

Specifically, most spherical mercator maps use an extent of the world from -180 to 180 longitude, and from -85.0511 to 85.0511 latitude. Because the mercator projection stretches to infinity as you approach the poles, a cutoff in the north-south direction is required, and this particular cutoff results in a perfect square of projected meters.

关于javascript - OpenLayers LonLat 转换不在正确的投影范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22823285/

相关文章:

用于解析搜索参数的 Javascript RegEx

javascript - 使用ajax填充谷歌地图标记

google-maps - 使用 Google Places API 时, "using the JavaScript library"和 "calling the API directly"有什么区别?

ios - 使用适用于 iOS 的 Google Maps SDK 时内存和 CPU 使用率非常高

javascript - 如何使用 Open Layers 下载、存储和加载图 block ?

javascript - 插件覆盖了一些 jQuery UI 函数

javascript - 页面加载后基于复选框隐藏/显示 div

google-maps - OpenLayers 2.13.1 与谷歌地图

javascript - 使用 openlayer3 初始化 map 后如何在 View 中设置范围属性?

javascript - iOS 上的 IFrame 高度问题(移动版 safari)