aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/MapRoutePath.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/map/MapRoutePath.js')
-rw-r--r--modern/src/map/MapRoutePath.js100
1 files changed, 0 insertions, 100 deletions
diff --git a/modern/src/map/MapRoutePath.js b/modern/src/map/MapRoutePath.js
deleted file mode 100644
index 18069a71..00000000
--- a/modern/src/map/MapRoutePath.js
+++ /dev/null
@@ -1,100 +0,0 @@
-import { useTheme } from '@mui/styles';
-import { useId, useEffect } from 'react';
-import { useSelector } from 'react-redux';
-import { map } from './core/MapView';
-import { findFonts } from './core/mapUtil';
-
-const MapRoutePath = ({ name, positions, coordinates }) => {
- const id = useId();
-
- const theme = useTheme();
-
- const reportColor = useSelector((state) => {
- const position = positions?.find(() => true);
- if (position) {
- const attributes = state.devices.items[position.deviceId]?.attributes;
- if (attributes) {
- const color = attributes['web.reportColor'];
- if (color) {
- return color;
- }
- }
- }
- return theme.palette.geometry.main;
- });
-
- useEffect(() => {
- map.addSource(id, {
- type: 'geojson',
- data: {
- type: 'Feature',
- geometry: {
- type: 'LineString',
- coordinates: [],
- },
- },
- });
- map.addLayer({
- source: id,
- id: `${id}-line`,
- type: 'line',
- layout: {
- 'line-join': 'round',
- 'line-cap': 'round',
- },
- paint: {
- 'line-color': ['get', 'color'],
- 'line-width': 2,
- },
- });
- if (name) {
- map.addLayer({
- source: id,
- id: `${id}-title`,
- type: 'symbol',
- layout: {
- 'text-field': '{name}',
- 'text-font': findFonts(map),
- 'text-size': 12,
- },
- paint: {
- 'text-halo-color': 'white',
- 'text-halo-width': 1,
- },
- });
- }
-
- return () => {
- if (map.getLayer(`${id}-title`)) {
- map.removeLayer(`${id}-title`);
- }
- if (map.getLayer(`${id}-line`)) {
- map.removeLayer(`${id}-line`);
- }
- if (map.getSource(id)) {
- map.removeSource(id);
- }
- };
- }, []);
-
- useEffect(() => {
- if (!coordinates) {
- coordinates = positions.map((item) => [item.longitude, item.latitude]);
- }
- map.getSource(id)?.setData({
- type: 'Feature',
- geometry: {
- type: 'LineString',
- coordinates,
- },
- properties: {
- name,
- color: reportColor,
- },
- });
- }, [theme, positions, coordinates, reportColor]);
-
- return null;
-};
-
-export default MapRoutePath;