Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions apps/frontend/src/components/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import generateTriangleSVG from '../../images/markers/triangle';
import generateStarSVG from '../../images/markers/star';
import generatePentagonSVG from '../../images/markers/pentagon';
import generateOtherSVG from '../../images/markers/other';
import PopupBox from '../mapIcon/PopupBox';
import { createRoot } from 'react-dom/client';
import { createPortal } from 'react-dom';
Expand All @@ -31,7 +32,9 @@
'Porous Paving': generateDiamondSVG,
'Tree Trench/Pit': generateStarSVG,
'Green Roof/Planter': generatePentagonSVG,
'Other': generatePentagonSVG,

'Other': generateOtherSVG // Placeholder, will remove

} as const;

type SymbolType = keyof typeof iconGenerators;
Expand All @@ -50,7 +53,7 @@
if (selectedFeatures.length === 0) {
markers.forEach((marker: google.maps.Marker) => {
marker.setMap(map);
});
});
tempMarkers = markers;
} else {
markers.forEach((marker: google.maps.Marker) => marker.setMap(null));
Expand Down Expand Up @@ -87,7 +90,7 @@
const Map: React.FC<MapProps> = ({ zoom, selectedFeatures, selectedStatuses }) => {
const mapRef = useRef<HTMLDivElement | null>(null);
const [showSignUp, setShowSignUp] = useState(false);
const [markers, setMarkers] = useState<google.maps.Marker[]>([]);

Check warning on line 93 in apps/frontend/src/components/map/Map.tsx

View workflow job for this annotation

GitHub Actions / pre-deploy

'markers' is assigned a value but never used
// CHANGED: State to store the selected site's ID.
const [selectedSiteId, setSelectedSiteId] = useState<string | null>(null);

Expand All @@ -96,7 +99,7 @@
useEffect(() => {
if (mapRef.current) {
loader.load().then(async () => {
map = new google.maps.Map(mapRef.current as HTMLElement, {

Check warning on line 102 in apps/frontend/src/components/map/Map.tsx

View workflow job for this annotation

GitHub Actions / pre-deploy

Assignments to the 'map' variable from inside React Hook useEffect will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useEffect
center: { lat: 42.36, lng: -71.06 },
zoom: zoom,
mapId: '3aa9b524d13192b',
Expand All @@ -121,15 +124,25 @@
const sites = await fetchAllSites();
const markersArray: google.maps.Marker[] = [];

sites.forEach((markerInfo: any) => {

Check warning on line 127 in apps/frontend/src/components/map/Map.tsx

View workflow job for this annotation

GitHub Actions / pre-deploy

Unexpected any. Specify a different type
const symbolType = markerInfo.symbolType;

if (!isValidSymbolType(symbolType)) {
console.warn(`Unknown symbol type: ${symbolType}`);
return;
}


let typeColor = '#58585B';
if (markerInfo.siteStatus === 'Available') {
typeColor = '#2D6A4F'; // Green
} else if (markerInfo.siteStatus === 'Adopted') {
typeColor = '#DFC22A'; // Yellow (match legend)
} else if (markerInfo.siteStatus === 'Inactive') {
typeColor = '#58585B'; // Gray
}


const typeColor = markerInfo.siteStatus === 'Available' ? '#2D6A4F' : '#FB4D42';
const generateIcon = iconGenerators[symbolType];
const tempIcon = generateIcon(typeColor);
const typeIcon = `data:image/svg+xml;utf8,${encodeURIComponent(tempIcon)}`;
Expand Down
Loading
Loading