2016-11-20 121 views

回答

1

如果你想畫設定點之間的線,第一變換每個座標

points.push(ol.proj.transform([xx,yy],'EPSG:4326', 'EPSG:3857')); 

然後創建LineString的幾何

var thing = new ol.geom.LineString(points); 

,並創建一個功能,並把它添加到層

var feature = new ol.Feature({ 
    name: "Thing", 
    geometry: thing 
    }) 
}); 

vectorSource.addFeature(feature); 

演示 https://plnkr.co/edit/WqWoFzjQdPDRkAjeXOGn?p=preview