1

I hope to find a quick answer for my problem.

I am using openlayer directive (https://github.com/tombatossals/angular-openlayers-directive) to draw a map in my App. I would like to add polyline to the map which shows a route on this map.

I could not find any solution for this. Is it possible to draw these lines?

Thank you for your help!

mayu
  • 221
  • 2
  • 7

1 Answers1

1

If you want to draw a line between set of points, first transform each co-ordinate

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

then create LineString Geometry

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

and create a feature and add it to a layer

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

vectorSource.addFeature( feature );

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

Naghaveer R
  • 2,890
  • 4
  • 30
  • 52