From dda384688c57b02b1260d92d0902f6d512b5c580 Mon Sep 17 00:00:00 2001 From: R Ranathunga Date: Mon, 10 Mar 2025 14:16:23 -0700 Subject: [PATCH] chore: hide layer control when map collapsed --- app/components/Analyst/Map/SummaryMap.tsx | 25 +++++++++++++++++++---- app/components/Analyst/SideMap.tsx | 7 ++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/components/Analyst/Map/SummaryMap.tsx b/app/components/Analyst/Map/SummaryMap.tsx index 567cc17e9c..91f488a480 100644 --- a/app/components/Analyst/Map/SummaryMap.tsx +++ b/app/components/Analyst/Map/SummaryMap.tsx @@ -21,8 +21,23 @@ import { ScaleControl, } from 'react-leaflet'; import { useEffect, useRef, useState } from 'react'; +import styled from 'styled-components'; import styles from './Tooltip.module.css'; +interface SummaryMapProps { + height: string; + width: string; + expanded?: boolean; +} + +const StyledMapContainer = styled(MapContainer)` + height: ${(props) => props.height}; + width: ${(props) => props.width}; + .leaflet-control-layers { + visibility: ${(props) => (props.expanded ? 'visible' : 'hidden')}; + } +`; + const generateUniqueKey = () => { return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; }; @@ -92,7 +107,7 @@ const RenderMarkers = ({ markers, name }) => ( ); -const SummaryMap = ({ initialData, height, width }) => { +const SummaryMap = ({ initialData, height, width, expanded = true }) => { const data = initialData; const tooltipClass = styles['tooltip-map']; const tooltipTextClass = styles['tooltip-text-map']; @@ -105,7 +120,7 @@ const SummaryMap = ({ initialData, height, width }) => { } }, [data, mapReady]); return ( - { // Zoom is automatically set when using bounds // zoom={5} scrollWheelZoom - style={{ height, width }} whenReady={() => { setMapReady(true); }} + height={height} + width={width} + expanded={expanded} > { )} - + ); }; diff --git a/app/components/Analyst/SideMap.tsx b/app/components/Analyst/SideMap.tsx index ecf9bec474..f4b630a35f 100644 --- a/app/components/Analyst/SideMap.tsx +++ b/app/components/Analyst/SideMap.tsx @@ -26,7 +26,12 @@ const SideMap = ({ mapData, isMapExpanded, setIsMapExpanded }) => { {!isMapExpanded && ( <> - + {