Draw line between two points using OpenLayers

后端 未结 2 795
借酒劲吻你
借酒劲吻你 2021-01-04 02:39

I have two points having lolLat as 0,10 and 30,0

Now to draw a marker at this point i use this transform while generating marker for it

lonLat.transf         


        
2条回答
  •  囚心锁ツ
    2021-01-04 03:29

    For example:

    map = new OpenLayers.Map();
    
    var start_point = new OpenLayers.Geometry.Point(0,10);
    var end_point = new OpenLayers.Geometry.Point(30,0);
    
    var vector = new OpenLayers.Layer.Vector();
    vector.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([start_point, end_point]))]);
    map.addLayers([vector]);
    

    Live demo

提交回复
热议问题