Skip to content

Commit

Permalink
Merge pull request #37 from r00tat/bugfix/position-tracking
Browse files Browse the repository at this point in the history
Fix position tracking
  • Loading branch information
r00tat authored Jan 18, 2024
2 parents b2293c1 + 970a8ae commit 0ba61ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Map/RecordButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function RecordButton() {
});

useEffect(() => {
if (isRecording && isPositionSet && recordItem && positions.length > 0) {
if (isRecording && isPositionSet && recordItem) {
const lastPos = positions[positions.length - 1];
const distance = position.distanceTo(toLatLng(lastPos[0], lastPos[1]));

Expand All @@ -111,7 +111,7 @@ export default function RecordButton() {
if ((distance > 5 && timeSinceLastPos > 1) || timeSinceLastPos > 30) {
map.setView(position);
setTimestamp(new Date());
addPos([lastPos[0], lastPos[1]], recordItem);
addPos([position.lat, position.lng], recordItem);
}
}
}, [
Expand Down

0 comments on commit 0ba61ea

Please sign in to comment.