blob: 279f3a85c54706708b6b68ae93271ae4098827f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
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';
import { useAttributePreference } from '../common/util/preferences';
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 mapLiveRoutes = useAttributePreference('mapLiveRoutes', false);
const onMarkerClick = useCallback((_, deviceId) => {
dispatch(devicesActions.select(deviceId));
}, [dispatch]);
return (
<>
<MapView>
<MapOverlay />
<MapGeofence />
<MapAccuracy positions={filteredPositions} />
{mapLiveRoutes && <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;
|