aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/MapRoutePath.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-02-02 15:34:48 -0800
committerAnton Tananaev <anton@traccar.org>2023-02-02 15:34:48 -0800
commit5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd (patch)
tree6358da297316e105de55aa80e22953e3feb10c2d /modern/src/map/MapRoutePath.js
parentcdfa3e5a8fca1b3b8ed59881adcaa8c3d686de50 (diff)
downloadtrackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.tar.gz
trackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.tar.bz2
trackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.zip
Base combined report
Diffstat (limited to 'modern/src/map/MapRoutePath.js')
-rw-r--r--modern/src/map/MapRoutePath.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/modern/src/map/MapRoutePath.js b/modern/src/map/MapRoutePath.js
index 0eb48bdc..ffd3ce0c 100644
--- a/modern/src/map/MapRoutePath.js
+++ b/modern/src/map/MapRoutePath.js
@@ -3,13 +3,13 @@ import { useId, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { map } from './core/MapView';
-const MapRoutePath = ({ positions }) => {
+const MapRoutePath = ({ positions, coordinates }) => {
const id = useId();
const theme = useTheme();
const reportColor = useSelector((state) => {
- const position = positions.find(() => true);
+ const position = positions?.find(() => true);
if (position) {
const attributes = state.devices.items[position.deviceId]?.attributes;
if (attributes) {
@@ -58,7 +58,9 @@ const MapRoutePath = ({ positions }) => {
}, []);
useEffect(() => {
- const coordinates = positions.map((item) => [item.longitude, item.latitude]);
+ if (!coordinates) {
+ coordinates = positions.map((item) => [item.longitude, item.latitude]);
+ }
map.getSource(id).setData({
type: 'Feature',
geometry: {
@@ -69,7 +71,7 @@ const MapRoutePath = ({ positions }) => {
color: reportColor,
},
});
- }, [theme, positions, reportColor]);
+ }, [theme, positions, coordinates, reportColor]);
return null;
};