blob: c46ea40e7a629d1c60ee8e9d62b231f419f7aaa8 (
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
|
import { useEffect } from 'react';
import { useSelector } from 'react-redux';
import dimensions from '../theme/dimensions';
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,
offset: [0, -dimensions.popupMapOffset / 2],
});
}
}, [mapCenter]);
return null;
};
export default SelectedDeviceMap;
|