mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
copy coordinates button for POIs, closes #195
This commit is contained in:
23
website/src/lib/components/gpx-layer/CopyCoordinates.svelte
Normal file
23
website/src/lib/components/gpx-layer/CopyCoordinates.svelte
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Button } from '$lib/components/ui/button';
|
||||||
|
import { ClipboardCopy } from 'lucide-svelte';
|
||||||
|
import { _ } from 'svelte-i18n';
|
||||||
|
import type { Coordinates } from 'gpx';
|
||||||
|
|
||||||
|
export let coordinates: Coordinates;
|
||||||
|
export let onCopy: () => void = () => {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
class="w-full px-2 py-1 h-8 justify-start {$$props.class}"
|
||||||
|
variant="outline"
|
||||||
|
on:click={() => {
|
||||||
|
navigator.clipboard.writeText(
|
||||||
|
`${coordinates.lat.toFixed(6)}, ${coordinates.lon.toFixed(6)}`
|
||||||
|
);
|
||||||
|
onCopy();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ClipboardCopy size="16" class="mr-1" />
|
||||||
|
{$_('menu.copy_coordinates')}
|
||||||
|
</Button>
|
@@ -1,10 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { TrackPoint } from 'gpx';
|
import type { TrackPoint } from 'gpx';
|
||||||
import type { PopupItem } from '$lib/components/MapPopup';
|
import type { PopupItem } from '$lib/components/MapPopup';
|
||||||
|
import CopyCoordinates from '$lib/components/gpx-layer/CopyCoordinates.svelte';
|
||||||
import * as Card from '$lib/components/ui/card';
|
import * as Card from '$lib/components/ui/card';
|
||||||
import { Button } from '$lib/components/ui/button';
|
|
||||||
import WithUnits from '$lib/components/WithUnits.svelte';
|
import WithUnits from '$lib/components/WithUnits.svelte';
|
||||||
import { Compass, Mountain, Timer, ClipboardCopy } from 'lucide-svelte';
|
import { Compass, Mountain, Timer } from 'lucide-svelte';
|
||||||
import { df } from '$lib/utils';
|
import { df } from '$lib/utils';
|
||||||
import { _ } from 'svelte-i18n';
|
import { _ } from 'svelte-i18n';
|
||||||
|
|
||||||
@@ -34,18 +34,10 @@
|
|||||||
{df.format(trackpoint.item.time)}
|
{df.format(trackpoint.item.time)}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<CopyCoordinates
|
||||||
class="w-full px-2 py-1 h-6 justify-start mt-0.5"
|
coordinates={trackpoint.item.attributes}
|
||||||
variant="secondary"
|
onCopy={() => trackpoint.hide?.()}
|
||||||
on:click={() => {
|
class="mt-0.5"
|
||||||
navigator.clipboard.writeText(
|
/>
|
||||||
`${trackpoint.item.getLatitude().toFixed(6)}, ${trackpoint.item.getLongitude().toFixed(6)}`
|
|
||||||
);
|
|
||||||
trackpoint.hide?.();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ClipboardCopy size="16" class="mr-1" />
|
|
||||||
{$_('menu.copy_coordinates')}
|
|
||||||
</Button>
|
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
import * as Card from '$lib/components/ui/card';
|
import * as Card from '$lib/components/ui/card';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import Shortcut from '$lib/components/Shortcut.svelte';
|
import Shortcut from '$lib/components/Shortcut.svelte';
|
||||||
|
import CopyCoordinates from '$lib/components/gpx-layer/CopyCoordinates.svelte';
|
||||||
import { deleteWaypoint } from './GPXLayerPopup';
|
import { deleteWaypoint } from './GPXLayerPopup';
|
||||||
import WithUnits from '$lib/components/WithUnits.svelte';
|
import WithUnits from '$lib/components/WithUnits.svelte';
|
||||||
import { Dot, ExternalLink, Trash2 } from 'lucide-svelte';
|
import { Dot, ExternalLink, Trash2 } from 'lucide-svelte';
|
||||||
@@ -77,9 +78,11 @@
|
|||||||
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.cmt)}</span>
|
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.cmt)}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
<div class="mt-2 flex flex-col gap-1">
|
||||||
|
<CopyCoordinates coordinates={waypoint.item.attributes} />
|
||||||
{#if $currentTool === Tool.WAYPOINT}
|
{#if $currentTool === Tool.WAYPOINT}
|
||||||
<Button
|
<Button
|
||||||
class="mt-2 w-full px-2 py-1 h-8 justify-start"
|
class="w-full px-2 py-1 h-8 justify-start"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
on:click={() => deleteWaypoint(waypoint.fileId, waypoint.item._data.index)}
|
on:click={() => deleteWaypoint(waypoint.fileId, waypoint.item._data.index)}
|
||||||
>
|
>
|
||||||
@@ -88,6 +91,7 @@
|
|||||||
<Shortcut shift={true} click={true} />
|
<Shortcut shift={true} click={true} />
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user