【问题标题】:Is there any projection that doesn’t clamp values when calling toLonLat()?调用 toLonLat() 时是否有任何投影不会限制值?
【发布时间】:2019-02-05 18:18:20
【问题描述】:

在 OpenLayers 5 中,当使用 const extent = this.view.calculateExtent(this.map.getSize()) 获取视图范围,然后使用 toLonLat() 将其转换为 latLng 时,如果地图处于非常低的缩放比例,结果值将被限制(经度为 -180 到 180)级别。

有什么方法可以避免这种钳位,例如使用另一个投影或另一个函数?

【问题讨论】:

  • 您可以使用ol.proj.transform() 或ol.proj.transformExtent() 转换为'EPSG:4326'。与toLonLat() 不同,它们不会标准化经度。

标签: openlayers map-projections openlayers-5


【解决方案1】:

我会自己回答。查看代码toLonLat() 应用等效于transform(coordinate, 'EPSG:3857', 'EPSG:4326') 的变换,然后钳位经度。所以答案是使用transform() 而不是toLonLat()。此外,还有一个transformExtent() 函数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-08
    • 1970-01-01
    • 2011-11-22
    • 2014-12-06
    • 2012-07-24
    相关资源
    最近更新 更多