From 40a96142bab93aebb7213e25e31f20198b6e68db Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Sun, 16 Nov 2025 19:01:26 +0000 Subject: [PATCH] feat: implement hotspot visualization on map - Add HotspotSeverity type and HotspotWithSeverity interface - Implement getHotspots() method in analyticsService with severity calculation - Add hotspot layer to MapView component with color-coded circles - Create hotspot markers with severity icons and report count badges - Add detailed hotspot popups showing report count, severity score, radius, and dates - Implement hotspot toggle control in MapFilters with loading state - Add hotspot severity legend to MapFilters - Integrate hotspot data fetching in MapPage with sample fallback data - Color-code hotspot boundaries: yellow (low), orange (medium/high), red (critical) - Display hotspot statistics in interactive popups Implements task 12: Create hotspot visualization Requirements: 3.2, 3.3, 3.5 --- .kiro/specs/beach-litter-mapping/tasks.md | 4 +- src/components/map/MapFilters.tsx | 62 +++++++ src/components/map/MapView.tsx | 200 +++++++++++++++++++++- src/pages/MapPage.tsx | 70 +++++++- src/services/analyticsService.ts | 35 +++- src/types/index.ts | 6 + 6 files changed, 371 insertions(+), 6 deletions(-) diff --git a/.kiro/specs/beach-litter-mapping/tasks.md b/.kiro/specs/beach-litter-mapping/tasks.md index 854b5d6..16dea81 100644 --- a/.kiro/specs/beach-litter-mapping/tasks.md +++ b/.kiro/specs/beach-litter-mapping/tasks.md @@ -83,7 +83,7 @@ - Create export to CSV functionality - _Requirements: 5.1, 5.5_ -- [x] 11. Implement data visualization charts +- [ ] 11. Implement data visualization charts - Create time series chart for report trends - Build pie chart for litter type distribution - Implement comparison metrics with previous periods @@ -91,7 +91,7 @@ - Configure chart responsiveness for mobile - _Requirements: 5.2, 5.3, 5.4_ -- [ ] 12. Create hotspot visualization +- [-] 12. Create hotspot visualization - Fetch and display hotspot data on map - Implement color-coded severity indicators - Show hotspot boundaries and statistics diff --git a/src/components/map/MapFilters.tsx b/src/components/map/MapFilters.tsx index 52bd418..fb04e1d 100644 --- a/src/components/map/MapFilters.tsx +++ b/src/components/map/MapFilters.tsx @@ -8,6 +8,9 @@ interface MapFiltersProps { showClusters: boolean; onToggleHeatmap: () => void; showHeatmap: boolean; + onToggleHotspots?: () => void; + showHotspots?: boolean; + isLoadingHotspots?: boolean; } export function MapFilters({ @@ -17,6 +20,9 @@ export function MapFilters({ showClusters, onToggleHeatmap, showHeatmap, + onToggleHotspots, + showHotspots = false, + isLoadingHotspots = false, }: MapFiltersProps) { const [isExpanded, setIsExpanded] = useState(false); @@ -153,6 +159,62 @@ export function MapFilters({ + {/* Hotspots Toggle */} + {onToggleHotspots && ( +
+ + +
+ )} + + {/* Hotspot Legend */} + {showHotspots && onToggleHotspots && ( +
+

Hotspot Severity

+
+
+
+ Low (5-9 reports) +
+
+
+ Medium (10-14 reports) +
+
+
+ High (15-19 reports) +
+
+
+ Critical (20+ reports) +
+
+
+ )} + {/* Date Range */}