【问题标题】:Transforming coordinates of feature in openlayers在openlayers中转换特征的坐标
【发布时间】:2016-03-21 15:19:13
【问题描述】:

我想在 openlayers 中转换整个功能的坐标。我已经成功使用 ol.proj.transform 将单个坐标转换为不同的投影,但是是否有任何功能可以提供整个特征,并且该特征中的所有坐标都将转换为所需的投影?提前感谢您提供的任何帮助!

【问题讨论】:

    标签: openlayers-3 projection


    【解决方案1】:

    我觉得你需要ol.geom.Geometry.transform

    如果你有你的功能,那么你可以这样做:

    src = 'EPSG:3857'
    dest = 'EPSG:4326'
    feature.getGeometry().transform(src, dest)
    

    文档在这里:

    http://openlayers.org/en/latest/apidoc/module-ol_geom_Geometry-Geometry.html#transform

    如果您不想原地修改几何图形,请先clone() 它,然后在克隆上使用此功能。

    【讨论】:

    • 谢谢!这就是解决方案。
    • 太好了,很高兴这对你有用。您能否将答案标记为“已接受”?这有助于其他用户知道问题已解决,从而使其更有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多