From f418231b6b2f5e030a0d2dcc390c314602b1f740 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Apr 2024 09:22:10 -0700 Subject: Move modern to the top --- modern/src/map/MapRoutePath.js | 100 ----------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 modern/src/map/MapRoutePath.js (limited to 'modern/src/map/MapRoutePath.js') 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; -- cgit v1.2.3