diff --git a/frontend/src/components/MapComponent.jsx b/frontend/src/components/MapComponent.jsx index fa4bd95..fad9cc3 100644 --- a/frontend/src/components/MapComponent.jsx +++ b/frontend/src/components/MapComponent.jsx @@ -191,34 +191,58 @@ export default function MapComponent() { const t = item.temp || item.Result; const name = item.siteName || item.Label || `User Point ${i + 1}`; - // Get current unit and format temperature + // determine age (fallback to createdAt for user‐points) + const rawTime = item.timestamp || item.createdAt || item.created_at; + const ts = new Date(rawTime).getTime(); + const isStale = !isNaN(ts) && (Date.now() - ts) > 2 * 24 * 60 * 60 * 1000; // older than 2 days + const currentUnit = UnitManager.getUnit(); const formattedTemp = formatTemperature(t, currentUnit); - const tempColor = getAccessibleTemperatureColor(t, 'C'); // Use accessible color function + const tempColor = getAccessibleTemperatureColor(t, 'C'); const tempCategory = getTemperatureCategory(t); - const tempSymbol = getTemperatureSymbol(t); - console.log(`Plotting [${i}]: ${name} @ ${lat},${lon} = ${formattedTemp}`); + // outline for stale, grey text for stale + const outlineStyle = isStale ? 'border: 2px solid grey;' : ''; + const valueColor = isStale ? 'color: grey;' : ''; + + // determine stale styling + const bgColor = isStale ? '#ffffff20' : tempColor; + const staleFilter = isStale + ? 'backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);' + : ''; const icon = L.divIcon({ className: 'custom-temp-marker', html: `
- ${formattedTemp} + ${formattedTemp}
`, - iconSize: [50, 40], // Slightly larger for better touch targets + iconSize: [50, 40], iconAnchor: [25, 20], }); - const marker = L.marker([lat, lon], { icon }).addTo(map); + const marker = L.marker([lat, lon], { icon }).addTo(mapInstanceRef.current); + + // bump this marker to the top on hover + marker.on('mouseover', () => { + marker.setZIndexOffset(1000); + }); + // reset when mouse leaves + marker.on('mouseout', () => { + marker.setZIndexOffset(0); + }); // Add function to announce to screen readers (this was missing) function announceToScreenReader(message) { @@ -240,24 +264,17 @@ export default function MapComponent() { // Add click handler FIRST (this is the main functionality) marker.on('click', async () => { - console.log('Marker clicked:', name); // Debug log - - // Announce to screen readers - try { - announceToScreenReader(`Viewing details for ${name} with water temperature ${formattedTemp}`); - } catch (e) { - console.log('Screen reader announcement failed:', e); - } + // add prefix for grey (stale) points + const labelPrefix = isStale ? 'OLD: ' : ''; const historicalData = await fetchHistoricalData(name); + const popupOffset = [17, -32]; - // add once at top of click‐handler so you can reuse - const popupOffset = [17, -32]; // x=0 (center), y=−45px (above marker) - + // no historical data if (historicalData.length === 0) { marker.bindPopup(`
- +

No historical data available

Current temperature: ${formattedTemp} (${tempCategory})

diff --git a/frontend/src/styles/MapView.css b/frontend/src/styles/MapView.css index 6b38098..ee27e5c 100644 --- a/frontend/src/styles/MapView.css +++ b/frontend/src/styles/MapView.css @@ -280,3 +280,8 @@ max-height: 60vh !important; } } + +/* at the end of the file, override any data-temp-category borders on stale points */ +.temp-label.stale { + border-left: none !important; +}