diff --git a/mapper/src/App.js b/mapper/src/App.js index 9ceec98..a363785 100644 --- a/mapper/src/App.js +++ b/mapper/src/App.js @@ -156,12 +156,18 @@ function Map({end, duration, slider, mapState, setMapState}) { const range = useMemo(() => parseSlider(end, duration, slider), [end, duration, slider]); const coords = useMemo(() => { - if (!data || !data.length) return []; + if (!Array.isArray(data)) return []; const result = []; + const [startTime, endTime] = range; + for (const point of data) { - if ((!range || (point.time >= range[0] && point.time <= range[1]))) { + // Ensure the point and its time exist before checking the range + if (!point || !point.time) continue; + + if (point.time >= startTime && point.time <= endTime) { const { lat, lon } = point; + // Strictest possible check for valid, finite, numeric coordinates if (typeof lat === 'number' && typeof lon === 'number' && isFinite(lat) && isFinite(lon)) { result.push([lat, lon]); }