@@ -121,6 +121,7 @@ function App () {
121121 const [ geojson , setGeojson ] = useState ( null ) ;
122122 const [ loading , setLoading ] = useState ( true ) ;
123123 const [ map , setMap ] = useState ( null ) ;
124+ const [ darkMode , setDarkMode ] = useState ( false ) ;
124125 let toDisplay , allResults = [ ] ;
125126
126127 useEffect ( ( ) => {
@@ -226,6 +227,10 @@ function App () {
226227 toDisplay = searchMapArea ( map ) ;
227228 }
228229
230+ function toggleDarkMode ( ) {
231+ setDarkMode ( ( prev ) => ! prev ) ;
232+ }
233+
229234 async function filterTableArea ( event ) {
230235 filterTable ( event , toDisplay ) ;
231236 }
@@ -274,15 +279,18 @@ function App () {
274279 < MapContainer ref = { setMap } center = { [ 51.505 , - 0.09 ] } zoom = { 13 } >
275280 < TileLayer
276281 attribution = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
277- url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
282+ url = { darkMode ? "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png" : "https://{s}. tile.openstreetmap.org/{z}/{x}/{y}.png"}
278283 />
279284 < GeoJSON data = { geojson } onEachFeature = { onEachFeature } />
280285 < div >
281286 < LocationMarker />
282- < Button onClick = { searchArea } buttonColour = "#f3f2f1" buttonHoverColour = "#ffdd00" buttonShadowColour = "#929191" buttonTextColour = "#0b0c0c"
287+ < Button onClick = { searchArea } buttonColour = "#f3f2f1" buttonHoverColour = "#ffdd00" buttonShadowColour = "#929191" buttonTextColour = "#0b0c0c"
283288 style = { { position : 'absolute' , bottom : '-4%' , marginLeft : "11em" , zIndex : 4000 , width : '170px' } } >
284289 Search this area
285- </ Button >
290+ </ Button >
291+ < Button onClick = { toggleDarkMode } style = { { position : 'absolute' , bottom : '-4%' , marginLeft : "24em" , zIndex : 4000 , width : '150px' } } >
292+ { darkMode ? 'Light Mode' : 'Dark Mode' }
293+ </ Button >
286294 </ div >
287295 </ MapContainer >
288296 </ div >
0 commit comments