@@ -11,6 +11,7 @@ import {
1111 getQueryStore ,
1212 getRouteStore ,
1313 getSettingsStore ,
14+ getCurrentLocationStore ,
1415} from '@/stores/Stores'
1516import MapComponent from '@/map/MapComponent'
1617import MapOptions from '@/map/MapOptions'
@@ -22,6 +23,7 @@ import { QueryStoreState, RequestState } from '@/stores/QueryStore'
2223import { RouteStoreState } from '@/stores/RouteStore'
2324import { MapOptionsStoreState } from '@/stores/MapOptionsStore'
2425import { ErrorStoreState } from '@/stores/ErrorStore'
26+ import { CurrentLocationStoreState } from '@/stores/CurrentLocationStore'
2527import Search from '@/sidebar/search/Search'
2628import ErrorMessage from '@/sidebar/ErrorMessage'
2729import useBackgroundLayer from '@/layers/UseBackgroundLayer'
@@ -45,6 +47,7 @@ import useExternalMVTLayer from '@/layers/UseExternalMVTLayer'
4547import LocationButton from '@/map/LocationButton'
4648import { SettingsContext } from '@/contexts/SettingsContext'
4749import usePOIsLayer from '@/layers/UsePOIsLayer'
50+ import useCurrentLocationLayer from '@/layers/UseCurrentLocationLayer'
4851
4952export const POPUP_CONTAINER_ID = 'popup-container'
5053export const SIDEBAR_CONTENT_ID = 'sidebar-content'
@@ -59,6 +62,7 @@ export default function App() {
5962 const [ pathDetails , setPathDetails ] = useState ( getPathDetailsStore ( ) . state )
6063 const [ mapFeatures , setMapFeatures ] = useState ( getMapFeatureStore ( ) . state )
6164 const [ pois , setPOIs ] = useState ( getPOIsStore ( ) . state )
65+ const [ currentLocation , setCurrentLocation ] = useState ( getCurrentLocationStore ( ) . state )
6266
6367 const map = getMap ( )
6468
@@ -72,6 +76,7 @@ export default function App() {
7276 const onPathDetailsChanged = ( ) => setPathDetails ( getPathDetailsStore ( ) . state )
7377 const onMapFeaturesChanged = ( ) => setMapFeatures ( getMapFeatureStore ( ) . state )
7478 const onPOIsChanged = ( ) => setPOIs ( getPOIsStore ( ) . state )
79+ const onCurrentLocationChanged = ( ) => setCurrentLocation ( getCurrentLocationStore ( ) . state )
7580
7681 getSettingsStore ( ) . register ( onSettingsChanged )
7782 getQueryStore ( ) . register ( onQueryChanged )
@@ -82,6 +87,7 @@ export default function App() {
8287 getPathDetailsStore ( ) . register ( onPathDetailsChanged )
8388 getMapFeatureStore ( ) . register ( onMapFeaturesChanged )
8489 getPOIsStore ( ) . register ( onPOIsChanged )
90+ getCurrentLocationStore ( ) . register ( onCurrentLocationChanged )
8591
8692 onQueryChanged ( )
8793 onInfoChanged ( )
@@ -91,6 +97,7 @@ export default function App() {
9197 onPathDetailsChanged ( )
9298 onMapFeaturesChanged ( )
9399 onPOIsChanged ( )
100+ onCurrentLocationChanged ( )
94101
95102 return ( ) => {
96103 getSettingsStore ( ) . deregister ( onSettingsChanged )
@@ -102,6 +109,7 @@ export default function App() {
102109 getPathDetailsStore ( ) . deregister ( onPathDetailsChanged )
103110 getMapFeatureStore ( ) . deregister ( onMapFeaturesChanged )
104111 getPOIsStore ( ) . deregister ( onPOIsChanged )
112+ getCurrentLocationStore ( ) . deregister ( onCurrentLocationChanged )
105113 }
106114 } , [ ] )
107115
@@ -116,6 +124,7 @@ export default function App() {
116124 useQueryPointsLayer ( map , query . queryPoints )
117125 usePathDetailsLayer ( map , pathDetails )
118126 usePOIsLayer ( map , pois )
127+ useCurrentLocationLayer ( map , currentLocation )
119128
120129 const isSmallScreen = useMediaQuery ( { query : '(max-width: 44rem)' } )
121130 return (
@@ -138,6 +147,7 @@ export default function App() {
138147 error = { error }
139148 encodedValues = { info . encoded_values }
140149 drawAreas = { settings . drawAreasEnabled }
150+ currentLocation = { currentLocation }
141151 />
142152 ) : (
143153 < LargeScreenLayout
@@ -148,6 +158,7 @@ export default function App() {
148158 error = { error }
149159 encodedValues = { info . encoded_values }
150160 drawAreas = { settings . drawAreasEnabled }
161+ currentLocation = { currentLocation }
151162 />
152163 ) }
153164 </ div >
@@ -160,12 +171,22 @@ interface LayoutProps {
160171 route : RouteStoreState
161172 map : Map
162173 mapOptions : MapOptionsStoreState
174+ currentLocation : CurrentLocationStoreState
163175 error : ErrorStoreState
164176 encodedValues : object [ ]
165177 drawAreas : boolean
166178}
167179
168- function LargeScreenLayout ( { query, route, map, error, mapOptions, encodedValues, drawAreas } : LayoutProps ) {
180+ function LargeScreenLayout ( {
181+ query,
182+ route,
183+ map,
184+ error,
185+ mapOptions,
186+ encodedValues,
187+ drawAreas,
188+ currentLocation,
189+ } : LayoutProps ) {
169190 const [ showSidebar , setShowSidebar ] = useState ( true )
170191 const [ showCustomModelBox , setShowCustomModelBox ] = useState ( false )
171192 return (
@@ -216,7 +237,7 @@ function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues
216237 < div className = { styles . popupContainer } id = { POPUP_CONTAINER_ID } />
217238 < div className = { styles . onMapRightSide } >
218239 < MapOptions { ...mapOptions } />
219- < LocationButton queryPoints = { query . queryPoints } />
240+ < LocationButton currentLocation = { currentLocation } />
220241 </ div >
221242 < div className = { styles . map } >
222243 < MapComponent map = { map } />
@@ -229,7 +250,16 @@ function LargeScreenLayout({ query, route, map, error, mapOptions, encodedValues
229250 )
230251}
231252
232- function SmallScreenLayout ( { query, route, map, error, mapOptions, encodedValues, drawAreas } : LayoutProps ) {
253+ function SmallScreenLayout ( {
254+ query,
255+ route,
256+ map,
257+ error,
258+ mapOptions,
259+ encodedValues,
260+ drawAreas,
261+ currentLocation,
262+ } : LayoutProps ) {
233263 return (
234264 < >
235265 < div className = { styles . smallScreenSidebar } >
@@ -248,7 +278,7 @@ function SmallScreenLayout({ query, route, map, error, mapOptions, encodedValues
248278 < div className = { styles . smallScreenMapOptions } >
249279 < div className = { styles . onMapRightSide } >
250280 < MapOptions { ...mapOptions } />
251- < LocationButton queryPoints = { query . queryPoints } />
281+ < LocationButton currentLocation = { currentLocation } />
252282 </ div >
253283 </ div >
254284
0 commit comments