I'm currently facing an issue where I am trying to display a set of values from an array, but it only seems to be showing the last value. How can I ensure that all values are displayed?
When I inspect longLat[itemIndex], I notice that the values should all be in the same array.
Collapsed:
https://i.sstatic.net/iwG8T.png
Expanded:
https://i.sstatic.net/9N0Vi.png
My code snippet-
let longLat = []
for (let index of this.overwatchTargets) {
let coordsArr = [index["longitude"], index["latitude"], index["userName"], index["dateTimeCaptured"]]
longLat.push(coordsArr)
for (let itemIndex in longLat) {
// Update location coordinates
this.map.getSource('data-source').setData({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
'description': "Dispatcher: " + longLat[itemIndex][2] + "\n" + "Lng/Lat: " + longLat[itemIndex][0] + " / " + longLat[itemIndex][1] + "\n" + "StartTime: " + longLat[itemIndex][3]
},
"geometry": {
"type": "Point",
"coordinates": longLat[itemIndex] <--- This should display all elements in the array, but it only shows the last one
}
}]
});
}
}