From f7b59e5eadf59515bf6e952cf4e7f7840c0b10c3 Mon Sep 17 00:00:00 2001 From: evlist Date: Sat, 3 Sep 2022 23:31:45 +0200 Subject: [PATCH] Reanbling background geolocation. --- src/components/gpx-overlay.tsx | 2 +- src/components/live-map.tsx | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/components/gpx-overlay.tsx b/src/components/gpx-overlay.tsx index 9b9f928..7b3bc6b 100644 --- a/src/components/gpx-overlay.tsx +++ b/src/components/gpx-overlay.tsx @@ -43,7 +43,7 @@ const GPXOverlay: React.FC<{ > )} diff --git a/src/components/live-map.tsx b/src/components/live-map.tsx index eed4940..5603659 100644 --- a/src/components/live-map.tsx +++ b/src/components/live-map.tsx @@ -38,7 +38,6 @@ const LiveMap: react.FC = () => { let [track, setTrack] = useState(emptyTrack); - /* useEffect(() => { console.log('com.dyomedea.dyomedea LOG', ' - Adding the watcher'); BackgroundGeolocation.addWatcher( @@ -99,10 +98,9 @@ const LiveMap: react.FC = () => { if (location !== undefined) { setCenter([location.latitude, location.longitude]); setPosition([location.latitude, location.longitude]); - track.geometry.coordinates.push([ - location.longitude, - location.latitude, - ]); + track.trkseg[0].trkpt.push({ + $: { lat: location.latitude, lon: location.longitude }, + }); setTrack(track); } @@ -117,16 +115,15 @@ const LiveMap: react.FC = () => { // When a watcher is no longer needed, it should be removed by calling // 'removeWatcher' with an object containing its ID. console.log('com.dyomedea.dyomedea LOG', ' - Watcher added'); - / *BackgroundGeolocation.removeWatcher({ + /*BackgroundGeolocation.removeWatcher({ id: watcher_id, - }); * / + }); */ }) .catch((reason) => { console.error('com.dyomedea.dyomedea LOG', ' - reason: ', reason); }); }, [track]); - */ return ( { animate={true} > - +