简体   繁体   English

如何在Openlayers3中从lon / lat画一条线

[英]How to draw a line from lon/lat in Openlayers3

How can i draw a Line in Openlayers 3? 如何在Openlayers 3中画线?

I was able to draw one with this code: 我能够用以下代码绘制一个:

var lineFeature = new ol.Feature(
                    new ol.geom.LineString([[-244780.24508882355, 5986452.183179816], [-1e6, 3e6]]));

But if i replace the coordinates with lon and lat coordinates, nothing happens. 但是,如果我将坐标替换为lon和lat坐标,则什么也不会发生。

In the API it says, i need a ol.coordinate Object for that... 在API中说,我需要一个ol.coordinate对象...

ol.proj.transform([7.520142, 53.803084], 'EPSG:4326', 'EPSG:3857')

worked. 工作了。 Just found it out :D 刚发现它:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM