I have a problem adding a list of points to a vector source, a layer and finally to the map in Openlayers. In the beginning I create an empty array, after that I iterate over a given data set and create a new Point with an Icon and a text field for every feature and store the marker in the list. In the end I want to create a new ol.source.Vector() with the array, which leads to the error 'c.Xa is not a function'. If I just take a single marker out of the list and add it to the vector source and the map everything works just fine with the right position on the map, right icon and right text.
var markers=[];
for(var i=1; i<ResearchStations.length; i++){
var mark=new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([lon, lat], proj3031)
),
});
var icon = new ol.style.Style({
image: new ol.style.Icon({
...
}),
text: new ol.style.Text({
...
})
})
mark.setStyle(icon);
markers[i]=mark;
}
console.log(1)
var vectorSource = new ol.source.Vector({
features: [markers],
});
console.log(2)
var StationLayer = new ol.layer.Vector({
source: vectorSource,
});
console.log(3)
map.addLayer(StationLayer);
The error occurs after console.log(1)