This should be a really quick and easy one. Sorry if there is a simple solution. I've read through the documentation but can't figure it out.
I've parsed a CSV using papa-parse.
var lyrHouses = Papa.parse('src/Houses.csv', {
header: true,
download: true,
dynamicTyping: true,
skipEmptyLines: true,
complete: function(results) {
console.log(results.data);
}
});
I would like to manipulate the array further.
How do I..
I thought this would be easy but after an hour, I can't figure out how to use the array properly.
Iterate through your results and create GeoJSON features/markers from your array.
housesGeoJSON = {
"type": "FeatureCollection",
"features": [ ]
}
var lyrHouses = Papa.parse('src/Houses.csv', {
header: true,
download: true,
dynamicTyping: true,
skipEmptyLines: true,
complete: function(results) {
results.data.forEach((house) => {
feature = {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [house.Longitude, house.Latitude]
},
"properties": {
"Location": house.Location
}
}
marker = L.geoJSON(feature).addTo(map)
// Create geojson of all markers push feature to the declared houses geoJSON
housesGeoJSON.features.push(feature)
})
}
});