|
2 | 2 | import { useCallback, useEffect, useState } from 'react' |
3 | 3 | import { Map, FullscreenControl, ScaleControl, NavigationControl, MapLayerMouseEvent, ViewStateChangeEvent, GeolocateControl } from 'react-map-gl/maplibre' |
4 | 4 | import * as maplibregl from 'maplibre-gl' |
| 5 | +import type { StyleSpecification } from 'maplibre-gl' |
5 | 6 | import { MapLibreEvent } from 'maplibre-gl' |
6 | 7 | import dynamic from 'next/dynamic' |
7 | | -import { MAP_STYLES, type MapStyles } from './MapSelector' |
8 | | -import { Drawer } from './TileHandlers/Drawer' |
9 | | -import { HoverCard } from './TileHandlers/HoverCard' |
10 | | -import { OBCustomLayers } from './OBCustomLayers' |
11 | | -import { tileToFeature } from './utils' |
12 | | -import { ActiveFeature, TileProps } from './TileTypes' |
13 | | -import MapLayersSelector from './MapLayersSelector' |
14 | | -import { MapToolbar } from './MapToolbar' |
15 | | -import { SelectedFeature } from './AreaActiveMarker' |
| 8 | +import { MAP_STYLES, type MapStyles } from '@/components/maps/MapSelector' |
| 9 | +import { Drawer } from '@/components/maps/TileHandlers/Drawer' |
| 10 | +import { HoverCard } from '@/components/maps/TileHandlers/HoverCard' |
| 11 | +import { OBCustomLayers } from '@/components/maps/OBCustomLayers' |
| 12 | +import { tileToFeature } from '@/components/maps/utils' |
| 13 | +import { ActiveFeature, TileProps } from '@/components/maps/TileTypes' |
| 14 | +import MapLayersSelector from '@/components/maps/MapLayersSelector' |
| 15 | +import { MapToolbar } from '@/components/maps/MapToolbar' |
| 16 | +import { SelectedFeature } from '@/components/maps/AreaActiveMarker' |
16 | 17 | import { useRouter } from 'next/navigation' |
17 | 18 | import { useUrlParams } from '@/js/hooks/useUrlParams' |
18 | 19 |
|
@@ -60,7 +61,8 @@ export const GlobalMap: React.FC<GlobalMapProps> = ({ |
60 | 61 | const [hoverInfo, setHoverInfo] = useState<ActiveFeature | null>(null) |
61 | 62 | const [mapInstance, setMapInstance] = useState<maplibregl.Map | null>(null) |
62 | 63 | const [cursor, setCursor] = useState<string>('default') |
63 | | - const [mapStyle, setMapStyle] = useState<string>(MAP_STYLES.light.style) |
| 64 | + const [mapStyle, setMapStyle] = useState<string | StyleSpecification>(MAP_STYLES.light.style) |
| 65 | + const [currentMapType, setCurrentMapType] = useState<keyof MapStyles>('light') |
64 | 66 | const [isSourceLoaded, setIsSourceLoaded] = useState(false) |
65 | 67 | const [dataLayersDisplayState, setDataLayersDisplayState] = useState<DataLayersDisplayState>({ |
66 | 68 | areaBoundaries: false, |
@@ -178,6 +180,7 @@ export const GlobalMap: React.FC<GlobalMapProps> = ({ |
178 | 180 | const updateMapLayer = (key: keyof MapStyles): void => { |
179 | 181 | const style = MAP_STYLES[key] |
180 | 182 | setMapStyle(style.style) |
| 183 | + setCurrentMapType(key) |
181 | 184 | } |
182 | 185 |
|
183 | 186 | const findAreaById = useCallback((map: maplibregl.Map, areaId: string) => { |
@@ -239,7 +242,7 @@ export const GlobalMap: React.FC<GlobalMapProps> = ({ |
239 | 242 | <MapLayersSelector emit={updateMapLayer} /> |
240 | 243 | <ScaleControl unit='imperial' style={{ marginBottom: 10 }} position='bottom-left' /> |
241 | 244 | <ScaleControl unit='metric' style={{ marginBottom: 0 }} position='bottom-left' /> |
242 | | - <OBCustomLayers layersState={dataLayersDisplayState} /> |
| 245 | + <OBCustomLayers layersState={dataLayersDisplayState} mapType={currentMapType} /> |
243 | 246 | {showFullscreenControl && <FullscreenControl />} |
244 | 247 | <NavigationControl showCompass={false} position='bottom-right' /> |
245 | 248 | <GeolocateControl |
|
0 commit comments