Storing the current track in pouchdb.

This commit is contained in:
vdv committed 2022-09-25 08:46:05 +02:00
1 parent 82997cd53f
commit 20ae635d3f
3 files changed
+77 -8

No files matched your search

+20 -6
View File
@@ -1,5 +1,6 @@
import { BackgroundGeolocationPlugin } from '@capacitor-community/background-geolocation';
import { registerPlugin } from '@capacitor/core';
import { appendTrkpt } from '../db/tracks';
const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>(
'BackgroundGeolocation'
@@ -34,7 +35,7 @@ const backgroundGeolocationConfig = {
distanceFilter: 1,
};
export const startBackgroundGeolocation = async () => {
export const startBackgroundGeolocation = async (db: any) => {
const locationHandler = (location: any, error: any) => {
console.log('com.dyomedea.dyomedea LOG', ' - Callback');
if (error) {
@@ -57,16 +58,29 @@ export const startBackgroundGeolocation = async () => {
}
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,
// },
// trkpt: {
// $: {
// lat: location.latitude,
// lon: location.longitude,
// },
// },
// })
// );