Complete Map and Popup
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import type { LayoutProps } from './$types';
|
||||
import ConnType2 from "$lib/icons/ConnType2.svelte";
|
||||
import Icon from "@iconify/svelte";
|
||||
|
||||
let { data, children }: LayoutProps = $props();
|
||||
const cc = $derived(data.chargecontroller);
|
||||
@@ -29,7 +31,23 @@
|
||||
</div>
|
||||
</div>
|
||||
{#await import('./Map.svelte') then { default: Map }}
|
||||
<Map class="grow h-10 -z-20" x={cc['latitude']} y={cc['longitude']}/>
|
||||
<Map class="grow h-10 -z-20" x={cc['latitude']} y={cc['longitude']}>
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="inline-flex items-center gap-2">
|
||||
<p class="!m-0">Informations</p>
|
||||
<div class="tooltip" data-tip="Type 2">
|
||||
<div class="w-5 h-5">
|
||||
<ConnType2/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full border-b border-b-gray-300"></div>
|
||||
<div class="inline-flex items-center gap-2">
|
||||
<Icon class="h-5 w-5 text-success" icon="mdi:checkbox-marked-circle"/>
|
||||
<p class="!m-0">Disponibile</p>
|
||||
</div>
|
||||
</div>
|
||||
</Map>
|
||||
{/await}
|
||||
</div>
|
||||
<div class="z-20 mt-16 grow pointer-events-none">
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
<script lang="ts">
|
||||
import * as L from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { onMount } from "svelte";
|
||||
import { onMount, type Snippet } from "svelte";
|
||||
import type { SvelteHTMLElements } from "svelte/elements";
|
||||
|
||||
type Props = {
|
||||
x: number,
|
||||
y: number,
|
||||
children?: Snippet,
|
||||
} & SvelteHTMLElements['div']
|
||||
|
||||
let { x, y, ...rest }: Props = $props();
|
||||
let { x, y, children, ...rest }: Props = $props();
|
||||
|
||||
let mapDiv: HTMLDivElement;
|
||||
let popupDiv: HTMLDivElement;
|
||||
let map: L.Map;
|
||||
|
||||
onMount(() => {
|
||||
@@ -20,9 +22,16 @@
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
}).addTo(map);
|
||||
L.marker([x, y]).addTo(map);
|
||||
const marker = L.marker([x, y]).addTo(map);
|
||||
if (children !== undefined)
|
||||
marker.bindPopup(popupDiv, { closeOnClick: false }).openPopup();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div bind:this={mapDiv} {...rest}>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
<div bind:this={popupDiv} class="h-full w-full">
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user