From 1f5f61835957839b343bf55d112fb6b236e1f9df Mon Sep 17 00:00:00 2001 From: trancen Date: Tue, 3 Feb 2026 18:23:52 +0000 Subject: [PATCH] fix: Lightning updates every 30s + add earthquake debug logging Lightning: - Strike IDs now include rounded timestamp (10s intervals) - This allows strikes to 'cycle' and be detected as new every 10 seconds - Strikes stay at same location but IDs change to trigger updates - Stats panel now updates properly every 30 seconds Earthquakes: - Added console logging to debug why markers don't appear - Logs: fetch count, enabled state, marker creation count - Will help identify if it's a data fetch or rendering issue --- src/plugins/layers/useEarthquakes.js | 7 ++++++- src/plugins/layers/useLightning.js | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/layers/useEarthquakes.js b/src/plugins/layers/useEarthquakes.js index a4bec29..bbd3bef 100644 --- a/src/plugins/layers/useEarthquakes.js +++ b/src/plugins/layers/useEarthquakes.js @@ -38,6 +38,7 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) { 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson' ); const data = await response.json(); + console.log('Earthquakes fetched:', data.features?.length || 0, 'quakes'); setEarthquakeData(data.features || []); } catch (err) { console.error('Earthquake data fetch error:', err); @@ -66,7 +67,10 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) { }); setMarkersRef([]); - if (!enabled || earthquakeData.length === 0) return; + if (!enabled || earthquakeData.length === 0) { + console.log('Earthquakes: enabled=', enabled, 'data count=', earthquakeData.length); + return; + } const newMarkers = []; const currentQuakeIds = new Set(); @@ -197,6 +201,7 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) { isFirstLoad.current = false; } + console.log('Earthquakes: Created', newMarkers.length, 'markers on map'); setMarkersRef(newMarkers); return () => { diff --git a/src/plugins/layers/useLightning.js b/src/plugins/layers/useLightning.js index 2b9cdb1..d14ea96 100644 --- a/src/plugins/layers/useLightning.js +++ b/src/plugins/layers/useLightning.js @@ -66,13 +66,14 @@ function generateSimulatedStrikes(count = 50) { const cycleMs = 30 * 60 * 1000; // 30 minute cycle const ageMs = ((now + (i * 10000)) % cycleMs); // Stagger ages const timestamp = now - ageMs; + const roundedTime = Math.floor(timestamp / 10000) * 10000; // Round to 10s for ID changes // Intensity fixed for this strike const intensity = (r2 * 200) - 50; // -50 to +150 kA const polarity = intensity >= 0 ? 'positive' : 'negative'; strikes.push({ - id: `strike_${i}_${lat}_${lon}`, // Index-based ID = always same + id: `strike_${i}_${lat}_${lon}_${roundedTime}`, // Include time for ID changes lat, // Fixed position lon, // Fixed position timestamp,