I'm currently developing a small web-application where I need to parse a csv into a GeoJSON. Therefore I use Papaparse. Whenever I parse the csv document, everything works but the coordinates in the geoJSON are undefined. I first thought it may not be able to access the s_lon, s_lat fields in the result after parsing the csv, but that's not the case, they can be perfectly accessed as can be seen in the logging. But it becomes even weirder, when I try to hard-code the coordinates in the coordinates array, they're undefined as well whenever the Feature get's returned. Does anyone has an idea where the problem might come from?
csvToGeojson(csvString) {
var self = this;
self.$papa.parse(csvString, {
// download: true,
header: true,
dynamicTyping: true,
skipEmptyLines: true,
complete: function (results) {
var geoJsonFeatureCollection = {
type: 'FeatureCollection',
features: results.data.map(function(datum) {
console.log(datum);
console.log(datum.s_lon, datum.s_lat);
return {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [datum.s_lon, datum.s_lat]
},
properties: datum
}
})
};
console.log("geoJsonFeatureCollection:")
console.log(geoJsonFeatureCollection);
self.$parent.addLayer(L.GeoJSON.canvasFlowmapLayer(geoJsonFeatureCollection, self.options));
}
})