Reputation: 74
I have an array filled with objects of the type ol.Feature which I am adding to a new object of the type ol.source.Vector, using the following code:
for (var i in stages)
{
console.log(stages[i].Longitude, stages[i].Latitude);
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([stages[i].Longitude, stages[i].Latitude], 'EPSG:4326', 'EPSG:3857')),
name: stages[i].Title
});
iconFeature.setStyle(iconStyle);
iconFeatures.push(iconFeatures);
}
try
{
var vectorSource = new ol.source.Vector({
features: iconFeatures
});
}
catch (e)
{
console.log(e);
}
The try/catch block was added because I didn't get any errors whatsoever (Angular/Ionic).
When I load the app, I'm getting the following error:
TypeError: feature.getId is not a function
var id = feature.getId();
Which redirects me to the linenumber of the console.log, meaning the error must be inside the creation of the vector source.
I'm completely stuck here, the examples that are all over the internet do it the same way, any help would be appriciated.
Upvotes: 1
Views: 5170
Reputation: 74
Apparently you can push an array to itself without getting any errors.
Totally my own fault
iconFeatures.push(iconFeatures);
should be
iconFeatures.push(iconFeature);
Upvotes: 2