gpt4 book ai didi

openlayers-3 - 开放层 3.6 : Getting the center of the current map view

转载 作者:行者123 更新时间:2023-12-04 05:09:25 27 4
gpt4 key购买 nike

我正在尝试以纬度/经度坐标获取 Openlayers map 的当前中心。我有以下事件处理程序设置:

this.map.on('pointermove', function (e) {
if (e.dragging) {
console.log(that.map.getView().getCenter());
}
});

这有效,但我得到了奇怪的值。下面是一个例子:
[9318218.659044644, 3274618.6225819485]

这些显然不是纬度/经度值:) 我需要以某种方式转换它吗?谢谢!

最佳答案

我对 openlayers 不是很熟悉,但听起来 map 在不同的投影中。

spherical_mercator 上查看以下内容, transform ,
Open Layers projections

更新
我做了更多的研究,看看这个 example .不确定您的 View 所在的投影。如果您转到 js 控制台并输入 map.getView().getCenter(),则此示例中的 map 位于“EPSG:21781”中。你得到 [693230.7161150641, 179010.3389264635]但是如果你输入 ol.proj.transform(map.getView().getCenter(), 'EPSG:21781', 'EPSG:4326')你得到 [8.658936030357363, 46.75575224283748]希望有帮助。

关于openlayers-3 - 开放层 3.6 : Getting the center of the current map view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31348541/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com