Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: hide layer control when map collapsed #3905

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 21 additions & 4 deletions app/components/Analyst/Map/SummaryMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)<SummaryMapProps>`
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)}`;
};
Expand Down Expand Up @@ -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'];
Expand All @@ -105,7 +120,7 @@ const SummaryMap = ({ initialData, height, width }) => {
}
}, [data, mapReady]);
return (
<MapContainer
<StyledMapContainer
preferCanvas
attributionControl={false}
ref={mapRef}
Expand All @@ -117,10 +132,12 @@ const SummaryMap = ({ initialData, height, width }) => {
// Zoom is automatically set when using bounds
// zoom={5}
scrollWheelZoom
style={{ height, width }}
whenReady={() => {
setMapReady(true);
}}
height={height}
width={width}
expanded={expanded}
>
<TileLayer
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
Expand Down Expand Up @@ -264,7 +281,7 @@ const SummaryMap = ({ initialData, height, width }) => {
</>
)}
</LayersControl>
</MapContainer>
</StyledMapContainer>
);
};

Expand Down
7 changes: 6 additions & 1 deletion app/components/Analyst/SideMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const SideMap = ({ mapData, isMapExpanded, setIsMapExpanded }) => {
<StyledMap>
{!isMapExpanded && (
<>
<MapCaller initialData={mapData} height="230px" width="230px" />
<MapCaller
initialData={mapData}
height="230px"
width="230px"
expanded={false}
/>
<StyledLink
data-testid="expand-map"
onClick={(e) => {
Expand Down
Loading