Move the current location on the map while recording (#12)

This commit is contained in:
vdv committed 2022-10-02 21:00:38 +02:00
1 parent e103e928b6
commit 924dd47395
2 files changed
+30 -32

No files matched your search

+3 -29
View File
@@ -1,6 +1,5 @@
import { BackgroundGeolocationPlugin } from '@capacitor-community/background-geolocation';
import { registerPlugin } from '@capacitor/core';
import { appendTrkpt } from '../db/gpx';
const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>(
'BackgroundGeolocation'
@@ -35,7 +34,7 @@ const backgroundGeolocationConfig = {
distanceFilter: 5,
};
export const startBackgroundGeolocation = async (db: any) => {
export const startBackgroundGeolocation = async (newLocationHandler: any) => {
const locationHandler = (location: any, error: any) => {
console.log('com.dyomedea.dyomedea LOG', ' - Callback');
if (error) {
@@ -58,33 +57,8 @@ export const startBackgroundGeolocation = async (db: any) => {
}
console.log(location);
if (location !== undefined) {
appendTrkpt(db, {
$: {
lat: location.latitude,
lon: location.longitude,
},
ele: location.altitude,
time: new Date(location.time).toISOString(),
extensions: {
speed: location.speed,
accuracy: location.accuracy,
},
});
//setCenter([location.latitude, location.longitude]);
//setPosition([location.latitude, location.longitude]);
// dispatch(
// gpxActions.appendTrkpt({
// trkKey: 'current',
// trkpt: {
// $: {
// lat: location.latitude,
// lon: location.longitude,
// },
// },
// })
// );
}
newLocationHandler(location);
}
return console.log('com.dyomedea.dyomedea LOG', ' - location: ', location);
};