feat: add geographic properties to displayed step record
All checks were successful
Migrate supabase / migrate (push) Successful in 15s

This commit is contained in:
2026-03-08 18:37:31 +01:00
parent 5e8b341733
commit 4897513689
2 changed files with 20 additions and 4 deletions

View File

@@ -100,7 +100,10 @@ export const load: LayoutServerLoad = async ({ params, url }) => {
description: displayedStepRecord.description ?? undefined, description: displayedStepRecord.description ?? undefined,
content: displayedStepRecord.content ?? undefined, content: displayedStepRecord.content ?? undefined,
type: displayedStepRecord.type, type: displayedStepRecord.type,
hint: displayedStepRecord.hint ?? undefined hint: displayedStepRecord.hint ?? undefined,
latitude: displayedStepRecord.latitude ?? null,
longitude: displayedStepRecord.longitude ?? null,
proximityRadius: displayedStepRecord.proximityRadius ?? 50
} }
: null, : null,
unlockedSteps: unlockedSteps.map((entry) => ({ unlockedSteps: unlockedSteps.map((entry) => ({

View File

@@ -80,7 +80,7 @@
return ((θ * 180) / Math.PI + 360) % 360; return ((θ * 180) / Math.PI + 360) % 360;
} }
// Update arrow rotation based on user heading and target bearing // Calculate distance - works independently of orientation
$effect(() => { $effect(() => {
if ( if (
currentStep?.type === 'location' && currentStep?.type === 'location' &&
@@ -97,7 +97,21 @@
currentStep.longitude currentStep.longitude
); );
distance = Math.round(dist); distance = Math.round(dist);
} else {
distance = null;
}
});
// Calculate arrow rotation - works with or without device orientation
$effect(() => {
if (
currentStep?.type === 'location' &&
isCurrentActiveStep &&
userLat !== null &&
userLon !== null &&
currentStep.latitude != null &&
currentStep.longitude != null
) {
const bearing = calculateBearing( const bearing = calculateBearing(
userLat, userLat,
userLon, userLon,
@@ -105,10 +119,9 @@
currentStep.longitude currentStep.longitude
); );
// If we have device heading, rotate relative to it; otherwise just use absolute bearing // If we have device heading, rotate relative to it; otherwise use absolute bearing (north = 0°)
arrowRotation = heading !== null ? bearing - heading : bearing; arrowRotation = heading !== null ? bearing - heading : bearing;
} else { } else {
distance = null;
arrowRotation = 0; arrowRotation = 0;
} }
}); });