2024-07-17 19:40:53 +02:00
|
|
|
<script lang="ts">
|
2025-02-02 11:17:22 +01:00
|
|
|
import * as Card from '$lib/components/ui/card';
|
|
|
|
|
import { Button } from '$lib/components/ui/button';
|
2025-06-21 21:07:36 +02:00
|
|
|
import { PencilLine, MapPin } from '@lucide/svelte';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { i18n } from '$lib/i18n/i18n.svelte';
|
2025-02-02 11:17:22 +01:00
|
|
|
import { ScrollArea } from '$lib/components/ui/scroll-area/index.js';
|
2025-11-10 13:11:44 +01:00
|
|
|
import type { PopupItem } from '$lib/components/map/map-popup';
|
2026-10-04 17:09:41 +02:00
|
|
|
import { engine } from '$lib/engine';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { selectionSize } from '$lib/engine/selection-helpers';
|
2026-10-04 17:09:41 +02:00
|
|
|
import { getElevation } from '$lib/utils';
|
2024-07-17 19:40:53 +02:00
|
|
|
|
2025-11-11 17:30:06 +01:00
|
|
|
let {
|
|
|
|
|
poi,
|
|
|
|
|
}: {
|
|
|
|
|
poi: PopupItem<any>;
|
|
|
|
|
} = $props();
|
2024-07-17 19:40:53 +02:00
|
|
|
|
2026-07-24 19:06:39 +02:00
|
|
|
let tags: Record<string, string> = $derived(
|
|
|
|
|
poi ? (typeof poi.item.tags == 'object' ? poi.item.tags : JSON.parse(poi.item.tags)) : {}
|
|
|
|
|
);
|
2025-11-11 17:30:06 +01:00
|
|
|
let name = $derived.by(() => {
|
|
|
|
|
if (poi) {
|
|
|
|
|
if (tags.name !== undefined && tags.name !== '') {
|
|
|
|
|
return tags.name;
|
|
|
|
|
} else {
|
|
|
|
|
return i18n._(`layers.label.${poi.item.query}`);
|
|
|
|
|
}
|
2025-02-02 11:17:22 +01:00
|
|
|
}
|
2025-11-11 17:30:06 +01:00
|
|
|
return '';
|
|
|
|
|
});
|
2025-06-04 18:55:14 +02:00
|
|
|
|
2026-10-04 17:09:41 +02:00
|
|
|
const { selection } = engine;
|
|
|
|
|
|
|
|
|
|
async function addToFile() {
|
2025-06-04 18:55:14 +02:00
|
|
|
const desc = Object.entries(tags)
|
|
|
|
|
.map(([key, value]) => `${key}: ${value}`)
|
|
|
|
|
.join('\n');
|
2026-10-08 18:34:19 +02:00
|
|
|
const [ele] = await getElevation([{ lat: poi.item.lat, lng: poi.item.lng }]);
|
2026-10-04 17:09:41 +02:00
|
|
|
await engine.newWaypoint({
|
|
|
|
|
lng: poi.item.lng,
|
|
|
|
|
lat: poi.item.lat,
|
|
|
|
|
ele,
|
|
|
|
|
name,
|
|
|
|
|
desc,
|
|
|
|
|
icon: poi.item.sym ?? '',
|
|
|
|
|
link: tags.website ?? '',
|
|
|
|
|
});
|
2025-06-04 18:55:14 +02:00
|
|
|
}
|
2024-07-17 19:40:53 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-11-09 20:11:35 +01:00
|
|
|
<Card.Root class="border-none shadow-md text-base p-2 max-w-[50dvw] gap-0">
|
|
|
|
|
<Card.Header class="p-0 gap-0">
|
2026-01-30 21:16:32 +01:00
|
|
|
<Card.Title class="text-md flex flex-row">
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
|
<p>{name}</p>
|
|
|
|
|
<div class="text-muted-foreground text-xs font-normal">
|
2026-10-04 17:09:41 +02:00
|
|
|
{poi.item.lat.toFixed(6)}° {poi.item.lng.toFixed(6)}°
|
2025-02-02 11:17:22 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-30 21:16:32 +01:00
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
class="ml-auto"
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="icon-sm"
|
|
|
|
|
href="https://www.openstreetmap.org/edit?editor=id&{poi.item.type ?? 'node'}={poi
|
|
|
|
|
.item.id}"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<PencilLine size="16" />
|
|
|
|
|
</Button>
|
2025-02-02 11:17:22 +01:00
|
|
|
</Card.Title>
|
|
|
|
|
</Card.Header>
|
2026-01-30 21:16:32 +01:00
|
|
|
<Card.Content class="flex flex-col gap-1 p-0 text-sm whitespace-normal break-all">
|
2025-11-09 19:52:02 +01:00
|
|
|
<ScrollArea class="flex flex-col max-h-[30dvh]">
|
2025-02-02 11:17:22 +01:00
|
|
|
{#if tags.image || tags['image:0']}
|
|
|
|
|
<div class="w-full rounded-md overflow-clip my-2 max-w-96 mx-auto">
|
2025-11-11 17:30:06 +01:00
|
|
|
<!-- svelte-ignore a11y_missing_attribute -->
|
2025-02-02 11:17:22 +01:00
|
|
|
<img src={tags.image ?? tags['image:0']} />
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="grid grid-cols-[auto_auto] gap-x-3">
|
|
|
|
|
{#each Object.entries(tags) as [key, value]}
|
|
|
|
|
{#if key !== 'name' && !key.includes('image')}
|
|
|
|
|
<span class="font-mono">{key}</span>
|
2025-11-09 20:14:52 +01:00
|
|
|
{#if key === 'website' || key.startsWith('website:') || key.endsWith(':website') || key === 'contact:facebook' || key === 'contact:instagram' || key === 'contact:twitter'}
|
2025-02-02 11:17:22 +01:00
|
|
|
<a href={value} target="_blank" class="text-link underline">{value}</a>
|
2026-06-03 19:05:15 +02:00
|
|
|
{:else if key === 'wikipedia' || key.startsWith('wikipedia:') || key.endsWith(':wikipedia')}
|
|
|
|
|
<a
|
|
|
|
|
href="https://wikipedia.org/wiki/{value}"
|
|
|
|
|
target="_blank"
|
|
|
|
|
class="text-link underline"
|
|
|
|
|
>
|
|
|
|
|
{value}
|
|
|
|
|
</a>
|
2025-02-02 11:17:22 +01:00
|
|
|
{:else if key === 'phone' || key === 'contact:phone'}
|
|
|
|
|
<a href={'tel:' + value} class="text-link underline">{value}</a>
|
|
|
|
|
{:else if key === 'email' || key === 'contact:email'}
|
|
|
|
|
<a href={'mailto:' + value} class="text-link underline">{value}</a>
|
|
|
|
|
{:else}
|
|
|
|
|
<span>{value}</span>
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</ScrollArea>
|
2026-01-30 21:16:32 +01:00
|
|
|
<Button
|
|
|
|
|
size="sm"
|
|
|
|
|
class="mt-1 justify-start"
|
|
|
|
|
variant="outline"
|
2026-10-04 17:09:41 +02:00
|
|
|
disabled={selectionSize($selection) === 0}
|
2026-01-30 21:16:32 +01:00
|
|
|
onclick={addToFile}
|
|
|
|
|
>
|
|
|
|
|
<MapPin size="14" />
|
2025-06-21 21:07:36 +02:00
|
|
|
{i18n._('toolbar.waypoint.add')}
|
2025-02-02 11:17:22 +01:00
|
|
|
</Button>
|
|
|
|
|
</Card.Content>
|
2024-10-08 15:49:14 +02:00
|
|
|
</Card.Root>
|