diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-21 12:54:25 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-21 12:54:25 -0700 |
commit | 4cce933164ace68833a07da463997e53226c1b6a (patch) | |
tree | 3f29997490a4f2d9b79305933a84a7efe1bbc9e3 /modern/src/map/MapDirection.js | |
parent | fb8f8764aae3e509df75f5d3f25daf11a19a0029 (diff) | |
download | trackermap-web-4cce933164ace68833a07da463997e53226c1b6a.tar.gz trackermap-web-4cce933164ace68833a07da463997e53226c1b6a.tar.bz2 trackermap-web-4cce933164ace68833a07da463997e53226c1b6a.zip |
Handle direction with clusering
Diffstat (limited to 'modern/src/map/MapDirection.js')
-rw-r--r-- | modern/src/map/MapDirection.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/modern/src/map/MapDirection.js b/modern/src/map/MapDirection.js deleted file mode 100644 index 2ccd508b..00000000 --- a/modern/src/map/MapDirection.js +++ /dev/null @@ -1,61 +0,0 @@ -import { useId, useEffect } from 'react'; -import { useAttributePreference } from '../common/util/preferences'; -import { map } from './core/MapView'; - -const MapDirection = ({ position }) => { - const id = useId(); - - const iconScale = useAttributePreference('iconScale', 1); - - useEffect(() => { - map.addSource(id, { - type: 'geojson', - data: { - type: 'FeatureCollection', - features: [], - }, - }); - map.addLayer({ - id, - type: 'symbol', - source: id, - layout: { - 'icon-image': 'direction', - 'icon-size': iconScale, - 'icon-rotate': ['get', 'rotation'], - 'icon-rotation-alignment': 'map', - }, - }); - - return () => { - if (map.getLayer(id)) { - map.removeLayer(id); - } - if (map.getSource(id)) { - map.removeSource(id); - } - }; - }, []); - - useEffect(() => { - map.getSource(id).setData({ - type: 'FeatureCollection', - features: [ - { - type: 'Feature', - geometry: { - type: 'Point', - coordinates: [position.longitude, position.latitude], - }, - properties: { - rotation: position.course, - }, - }, - ], - }); - }, [position]); - - return null; -}; - -export default MapDirection; |