mayu
mayu

Reputation: 221

Angularjs Openlayer draw polyline

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!

Upvotes: 1

Views: 761

Answers (1)

Naghaveer R
Naghaveer R

Reputation: 2944

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

Upvotes: 1

Related Questions