Adding multiple markers to map in open layers v4.2

Viewed 883

I imported a dataset of csv format using function d3.csv. The dataset contains lat and long fields. I tried adding the markers to the map by iterating through the dataset

d3.csv("xyz.csv", function(data) {
data.forEach( function(d) {

var pos = ol.proj.fromLonLat([d.longitude, d.latitude]);     
      var marker = new ol.Overlay({
        position: pos,
        positioning: 'center-center',
        element: document.getElementById('marker'),
        stopEvent: false
      });
      map.addOverlay(marker);
}
);

But could not make it. Do I have to use addFeature for this ?

0 Answers
Related