diff options
author | Anton Tananaev <anton@traccar.org> | 2024-04-06 09:22:10 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-04-06 09:22:10 -0700 |
commit | f418231b6b2f5e030a0d2dcc390c314602b1f740 (patch) | |
tree | 10326adf3792bc2697e06bb5f2b8ef2a8f7e55fe /src/main/MainMap.jsx | |
parent | b392a4af78e01c8e0f50aad5468e9583675b24be (diff) | |
download | trackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.tar.gz trackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.tar.bz2 trackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.zip |
Move modern to the top
Diffstat (limited to 'src/main/MainMap.jsx')
-rw-r--r-- | src/main/MainMap.jsx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/main/MainMap.jsx b/src/main/MainMap.jsx new file mode 100644 index 00000000..3b57c745 --- /dev/null +++ b/src/main/MainMap.jsx @@ -0,0 +1,66 @@ +import React, { useCallback } from 'react'; +import { useTheme } from '@mui/material/styles'; +import useMediaQuery from '@mui/material/useMediaQuery'; +import { useDispatch, useSelector } from 'react-redux'; +import MapView from '../map/core/MapView'; +import MapSelectedDevice from '../map/main/MapSelectedDevice'; +import MapAccuracy from '../map/main/MapAccuracy'; +import MapGeofence from '../map/MapGeofence'; +import MapCurrentLocation from '../map/MapCurrentLocation'; +import PoiMap from '../map/main/PoiMap'; +import MapPadding from '../map/MapPadding'; +import { devicesActions } from '../store'; +import MapDefaultCamera from '../map/main/MapDefaultCamera'; +import MapLiveRoutes from '../map/main/MapLiveRoutes'; +import MapPositions from '../map/MapPositions'; +import MapOverlay from '../map/overlay/MapOverlay'; +import MapGeocoder from '../map/geocoder/MapGeocoder'; +import MapScale from '../map/MapScale'; +import MapNotification from '../map/notification/MapNotification'; +import useFeatures from '../common/util/useFeatures'; + +const MainMap = ({ filteredPositions, selectedPosition, onEventsClick }) => { + const theme = useTheme(); + const dispatch = useDispatch(); + + const desktop = useMediaQuery(theme.breakpoints.up('md')); + + const eventsAvailable = useSelector((state) => !!state.events.items.length); + + const features = useFeatures(); + + const onMarkerClick = useCallback((_, deviceId) => { + dispatch(devicesActions.selectId(deviceId)); + }, [dispatch]); + + return ( + <> + <MapView> + <MapOverlay /> + <MapGeofence /> + <MapAccuracy positions={filteredPositions} /> + <MapLiveRoutes /> + <MapPositions + positions={filteredPositions} + onClick={onMarkerClick} + selectedPosition={selectedPosition} + showStatus + /> + <MapDefaultCamera /> + <MapSelectedDevice /> + <PoiMap /> + </MapView> + <MapScale /> + <MapCurrentLocation /> + <MapGeocoder /> + {!features.disableEvents && ( + <MapNotification enabled={eventsAvailable} onClick={onEventsClick} /> + )} + {desktop && ( + <MapPadding left={parseInt(theme.dimensions.drawerWidthDesktop, 10)} /> + )} + </> + ); +}; + +export default MainMap; |