Skip to content

Commit fdd224f

Browse files
RRanathccbc-service-account
authored andcommitted
chore: hide layer control when map collapsed
1 parent d9dc0a2 commit fdd224f

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

app/components/Analyst/Map/SummaryMap.tsx

+21-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,23 @@ import {
2121
ScaleControl,
2222
} from 'react-leaflet';
2323
import { useEffect, useRef, useState } from 'react';
24+
import styled from 'styled-components';
2425
import styles from './Tooltip.module.css';
2526

27+
interface SummaryMapProps {
28+
height: string;
29+
width: string;
30+
expanded?: boolean;
31+
}
32+
33+
const StyledMapContainer = styled(MapContainer)<SummaryMapProps>`
34+
height: ${(props) => props.height};
35+
width: ${(props) => props.width};
36+
.leaflet-control-layers {
37+
visibility: ${(props) => (props.expanded ? 'visible' : 'hidden')};
38+
}
39+
`;
40+
2641
const generateUniqueKey = () => {
2742
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
2843
};
@@ -92,7 +107,7 @@ const RenderMarkers = ({ markers, name }) => (
92107
</>
93108
);
94109

95-
const SummaryMap = ({ initialData, height, width }) => {
110+
const SummaryMap = ({ initialData, height, width, expanded = true }) => {
96111
const data = initialData;
97112
const tooltipClass = styles['tooltip-map'];
98113
const tooltipTextClass = styles['tooltip-text-map'];
@@ -105,7 +120,7 @@ const SummaryMap = ({ initialData, height, width }) => {
105120
}
106121
}, [data, mapReady]);
107122
return (
108-
<MapContainer
123+
<StyledMapContainer
109124
preferCanvas
110125
attributionControl={false}
111126
ref={mapRef}
@@ -117,10 +132,12 @@ const SummaryMap = ({ initialData, height, width }) => {
117132
// Zoom is automatically set when using bounds
118133
// zoom={5}
119134
scrollWheelZoom
120-
style={{ height, width }}
121135
whenReady={() => {
122136
setMapReady(true);
123137
}}
138+
height={height}
139+
width={width}
140+
expanded={expanded}
124141
>
125142
<TileLayer
126143
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
@@ -264,7 +281,7 @@ const SummaryMap = ({ initialData, height, width }) => {
264281
</>
265282
)}
266283
</LayersControl>
267-
</MapContainer>
284+
</StyledMapContainer>
268285
);
269286
};
270287

app/components/Analyst/SideMap.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ const SideMap = ({ mapData, isMapExpanded, setIsMapExpanded }) => {
2626
<StyledMap>
2727
{!isMapExpanded && (
2828
<>
29-
<MapCaller initialData={mapData} height="230px" width="230px" />
29+
<MapCaller
30+
initialData={mapData}
31+
height="230px"
32+
width="230px"
33+
expanded={false}
34+
/>
3035
<StyledLink
3136
data-testid="expand-map"
3237
onClick={(e) => {

0 commit comments

Comments
 (0)