From 060a7e6d15a7d93e9e819228679b2bc798e8bc34 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 13 Aug 2022 07:27:54 -0700 Subject: Filter position accuracy (fix #1014) --- modern/src/map/main/MapAccuracy.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'modern/src/map/main/MapAccuracy.js') 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; -- cgit v1.2.3