diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-13 07:27:54 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-13 07:27:54 -0700 |
commit | 060a7e6d15a7d93e9e819228679b2bc798e8bc34 (patch) | |
tree | 7432d36e05dd637014a43be07c83b38909774f40 /modern/src/map/main/MapAccuracy.js | |
parent | a34a1be52dc6b08f6691845487a7dfc843e774e3 (diff) | |
download | trackermap-web-060a7e6d15a7d93e9e819228679b2bc798e8bc34.tar.gz trackermap-web-060a7e6d15a7d93e9e819228679b2bc798e8bc34.tar.bz2 trackermap-web-060a7e6d15a7d93e9e819228679b2bc798e8bc34.zip |
Filter position accuracy (fix #1014)
Diffstat (limited to 'modern/src/map/main/MapAccuracy.js')
-rw-r--r-- | modern/src/map/main/MapAccuracy.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/modern/src/map/main/MapAccuracy.js b/modern/src/map/main/MapAccuracy.js index bec8bde8..335be58e 100644 --- a/modern/src/map/main/MapAccuracy.js +++ b/modern/src/map/main/MapAccuracy.js @@ -1,21 +1,13 @@ import { useId, useEffect } from 'react'; -import { useSelector } from 'react-redux'; import circle from '@turf/circle'; import { useTheme } from '@mui/styles'; import { map } from '../core/MapView'; -const MapAccuracy = () => { +const MapAccuracy = ({ positions }) => { const id = useId(); const theme = useTheme(); - const positions = useSelector((state) => ({ - type: 'FeatureCollection', - features: Object.values(state.positions.items) - .filter((position) => position.accuracy > 0) - .map((position) => circle([position.longitude, position.latitude], position.accuracy * 0.001)), - })); - useEffect(() => { map.addSource(id, { type: 'geojson', @@ -50,7 +42,13 @@ const MapAccuracy = () => { }, []); useEffect(() => { - map.getSource(id).setData(positions); + const data = { + type: 'FeatureCollection', + features: positions + .filter((position) => position.accuracy > 0) + .map((position) => circle([position.longitude, position.latitude], position.accuracy * 0.001)), + }; + map.getSource(id).setData(data); }, [positions]); return null; |