From ed425faf1a0cef1197e8f6fe82805fe1713d7871 Mon Sep 17 00:00:00 2001 From: Cfp Date: Sun, 22 Jun 2025 11:08:04 +0200 Subject: [PATCH] feat: location marker with remote location support --- src/lib/components/lnv/Map.svelte | 30 ++- src/lib/components/lnv/Sidebar.svelte | 38 +++- src/lib/components/lnv/location.svelte.ts | 183 ++++++++++++++++++ src/lib/components/lnv/map.svelte.ts | 6 +- src/lib/services/navigation/routing.svelte.ts | 9 +- 5 files changed, 257 insertions(+), 9 deletions(-) create mode 100644 src/lib/components/lnv/location.svelte.ts diff --git a/src/lib/components/lnv/Map.svelte b/src/lib/components/lnv/Map.svelte index 0e13572..5f07137 100644 --- a/src/lib/components/lnv/Map.svelte +++ b/src/lib/components/lnv/Map.svelte @@ -10,7 +10,7 @@ Protocol, } from "svelte-maplibre-gl"; import { view } from "./sidebar.svelte"; - import { geolocate, map, pin } from "./map.svelte"; + import { map, pin } from "./map.svelte"; import { drawAllRoutes, fetchRoute, @@ -18,11 +18,15 @@ } from "$lib/services/navigation/routing.svelte"; import { createValhallaRequest } from "$lib/vehicles/ValhallaVehicles"; import { ROUTING_SERVER } from "$lib/services/hosts"; + import { location } from "./location.svelte"; onMount(() => { window.addEventListener("resize", map.updateMapPadding); map.updateMapPadding(); }); + + let locationDot: HTMLDivElement | undefined = $state(); + let locationAccuracyCircle: HTMLDivElement | undefined = $state(); { map.updateMapPadding(); + location.locked = true; }} onclick={(e) => { if (view.current.type == "main" || view.current.type == "info") { @@ -67,9 +72,15 @@ pin.showInfo(); } }} + onmove={(e) => { + // @ts-ignore + if (e.reason !== "location") { + location.locked = false; + } + }} > - + /> --> {#if pin.isDropped} {/if} @@ -177,4 +188,17 @@ > {/if} + + {#if location.available} +
+
+ + + {/if} diff --git a/src/lib/components/lnv/Sidebar.svelte b/src/lib/components/lnv/Sidebar.svelte index eb1cdfa..414bc5e 100644 --- a/src/lib/components/lnv/Sidebar.svelte +++ b/src/lib/components/lnv/Sidebar.svelte @@ -8,10 +8,12 @@ import { map } from "./map.svelte"; import TripSidebar from "./sidebar/TripSidebar.svelte"; import Input from "../ui/input/input.svelte"; - import { HomeIcon, SettingsIcon, UserIcon } from "@lucide/svelte"; + import { EllipsisIcon, HomeIcon, SettingsIcon, UserIcon } from "@lucide/svelte"; import Button from "../ui/button/button.svelte"; import { search, type Feature } from "$lib/services/Search"; import SearchSidebar from "./sidebar/SearchSidebar.svelte"; + import { advertiseRemoteLocation, location, remoteLocation } from "./location.svelte"; + import * as Popover from "../ui/popover"; const views: {[key: string]: Component} = { main: MainSidebar, @@ -112,6 +114,40 @@ + + + + + + +
+ + {#if location.code} + Advertise code: {location.code} + {/if} + + +
+
+