@@ -21,8 +21,23 @@ import {
21
21
ScaleControl ,
22
22
} from 'react-leaflet' ;
23
23
import { useEffect , useRef , useState } from 'react' ;
24
+ import styled from 'styled-components' ;
24
25
import styles from './Tooltip.module.css' ;
25
26
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
+
26
41
const generateUniqueKey = ( ) => {
27
42
return `${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 ) } ` ;
28
43
} ;
@@ -92,7 +107,7 @@ const RenderMarkers = ({ markers, name }) => (
92
107
</ >
93
108
) ;
94
109
95
- const SummaryMap = ( { initialData, height, width } ) => {
110
+ const SummaryMap = ( { initialData, height, width, expanded = true } ) => {
96
111
const data = initialData ;
97
112
const tooltipClass = styles [ 'tooltip-map' ] ;
98
113
const tooltipTextClass = styles [ 'tooltip-text-map' ] ;
@@ -105,7 +120,7 @@ const SummaryMap = ({ initialData, height, width }) => {
105
120
}
106
121
} , [ data , mapReady ] ) ;
107
122
return (
108
- < MapContainer
123
+ < StyledMapContainer
109
124
preferCanvas
110
125
attributionControl = { false }
111
126
ref = { mapRef }
@@ -117,10 +132,12 @@ const SummaryMap = ({ initialData, height, width }) => {
117
132
// Zoom is automatically set when using bounds
118
133
// zoom={5}
119
134
scrollWheelZoom
120
- style = { { height, width } }
121
135
whenReady = { ( ) => {
122
136
setMapReady ( true ) ;
123
137
} }
138
+ height = { height }
139
+ width = { width }
140
+ expanded = { expanded }
124
141
>
125
142
< TileLayer
126
143
attribution = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
@@ -264,7 +281,7 @@ const SummaryMap = ({ initialData, height, width }) => {
264
281
</ >
265
282
) }
266
283
</ LayersControl >
267
- </ MapContainer >
284
+ </ StyledMapContainer >
268
285
) ;
269
286
} ;
270
287
0 commit comments