diff options
Diffstat (limited to 'modern/src/map/SelectedDeviceMap.js')
-rw-r--r-- | modern/src/map/SelectedDeviceMap.js | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/modern/src/map/SelectedDeviceMap.js b/modern/src/map/SelectedDeviceMap.js index 3a5c997..1d38a60 100644 --- a/modern/src/map/SelectedDeviceMap.js +++ b/modern/src/map/SelectedDeviceMap.js @@ -1,26 +1,26 @@ -import { useEffect } from 'react'; - -import { useSelector } from 'react-redux'; -import { map } from './Map'; - -const SelectedDeviceMap = () => { - const mapCenter = useSelector((state) => { - if (state.devices.selectedId) { - const position = state.positions.items[state.devices.selectedId] || null; - if (position) { - return { deviceId: state.devices.selectedId, position: [position.longitude, position.latitude] }; - } - } - return null; - }); - - useEffect(() => { - if (mapCenter) { - map.easeTo({ center: mapCenter.position, zoom: 18 }); - } - }, [mapCenter]); - - return null; -}; - -export default SelectedDeviceMap; +import { useEffect } from 'react';
+
+import { useSelector } from 'react-redux';
+import { map } from './Map';
+
+const SelectedDeviceMap = () => {
+ const mapCenter = useSelector((state) => {
+ if (state.devices.selectedId) {
+ const position = state.positions.items[state.devices.selectedId] || null;
+ if (position) {
+ return { deviceId: state.devices.selectedId, position: [position.longitude, position.latitude] };
+ }
+ }
+ return null;
+ });
+
+ useEffect(() => {
+ if (mapCenter) {
+ map.easeTo({ center: mapCenter.position, zoom: 18 });
+ }
+ }, [mapCenter]);
+
+ return null;
+};
+
+export default SelectedDeviceMap;
|