You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to build an app for running, so I'm trying to track the user position on a google map, but I get the position from the android device every 6/8 seconds, the strange thing is that on web it works perfectly. this is my code:
if (!this.isTracking) {
this.startTracking();
} else {
this.stopTracking();
}
}
// Use Capacitor to track our geolocation
startTracking() {
this.isTracking = true;
this.label = "Stop Tracking";
this.watch = Geolocation.watchPosition(
{
enableHighAccuracy: true,
maximumAge: 2000,
timeout: 0,
},
(position, err) => {
if (position) {
let date = new Date().toLocaleTimeString();
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.markerLat = position.coords.latitude;
this.markerLng = position.coords.longitude;
this.addNewLocation(
position.coords.latitude,
position.coords.longitude,
date
);
this.cdRef.detectChanges();
}
}
);
}
// Unsubscribe from the geolocation watch using the initial ID
stopTracking() {
Geolocation.clearWatch({ id: this.watch }).then(() => {
this.isTracking = false;
this.label = "Start Tracking";
});
}
// Save a new location to Firebase and center the map
addNewLocation(lat, lng, time) {
this.points.push({
lat,
lng,
time,
});
this.pointsView.unshift({
lat,
lng,
time,
});
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to build an app for running, so I'm trying to track the user position on a google map, but I get the position from the android device every 6/8 seconds, the strange thing is that on web it works perfectly. this is my code:
Beta Was this translation helpful? Give feedback.
All reactions