diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index a37bf60..f346d29 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -8,6 +8,11 @@ let position: GeolocationPosition | undefined = $state(undefined); let error: GeolocationError | undefined = $state(undefined); + // Manual coordinate entry + let manualLat: string = $state(''); + let manualLong: string = $state(''); + let manualError: string = $state(''); + let options = { enableHighAccuracy: false, // Use WiFi/network location (faster than GPS) timeout: 10000, // milliseconds - increased for better reliability @@ -23,22 +28,101 @@ function goToPlayer(): void { goto(`/on-out?lat=${position?.coords.latitude}&long=${position?.coords.longitude}`); } + + function goWithManualCoords(): void { + // Validate coordinates + const lat = parseFloat(manualLat); + const long = parseFloat(manualLong); + + if (isNaN(lat) || isNaN(long)) { + manualError = 'Please enter valid numbers'; + return; + } + + if (lat < -90 || lat > 90) { + manualError = 'Latitude must be between -90 and 90'; + return; + } + + if (long < -180 || long > 180) { + manualError = 'Longitude must be between -180 and 180'; + return; + } + + manualError = ''; + goto(`/on-out?lat=${lat}&long=${long}`); + } -