2025-06-21 21:07:36 +02:00
|
|
|
<script lang="ts">
|
2025-10-17 23:54:45 +02:00
|
|
|
import { streetViewEnabled } from '$lib/components/map/street-view-control/utils';
|
|
|
|
|
import { map } from '$lib/components/map/map';
|
2025-06-21 21:07:36 +02:00
|
|
|
import CustomControl from '$lib/components/map/custom-control/CustomControl.svelte';
|
|
|
|
|
import Tooltip from '$lib/components/Tooltip.svelte';
|
|
|
|
|
import { Toggle } from '$lib/components/ui/toggle';
|
|
|
|
|
import { PersonStanding, X } from '@lucide/svelte';
|
|
|
|
|
import { MapillaryLayer } from './Mapillary';
|
|
|
|
|
import { GoogleRedirect } from './Google';
|
2025-10-17 23:54:45 +02:00
|
|
|
import { settings } from '$lib/logic/settings';
|
2025-06-21 21:07:36 +02:00
|
|
|
import { i18n } from '$lib/i18n.svelte';
|
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
|
|
|
|
|
const { streetViewSource } = settings;
|
|
|
|
|
|
|
|
|
|
let googleRedirect: GoogleRedirect | null = $state(null);
|
|
|
|
|
let mapillaryLayer: MapillaryLayer | null = $state(null);
|
|
|
|
|
let mapillaryOpen = $state({
|
|
|
|
|
value: false,
|
|
|
|
|
});
|
|
|
|
|
let container: HTMLElement;
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
map.onLoad((map: mapboxgl.Map) => {
|
|
|
|
|
googleRedirect = new GoogleRedirect(map);
|
|
|
|
|
mapillaryLayer = new MapillaryLayer(map, container, mapillaryOpen);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$effect(() => {
|
2025-10-17 23:54:45 +02:00
|
|
|
if ($streetViewSource === 'mapillary') {
|
2025-06-21 21:07:36 +02:00
|
|
|
googleRedirect?.remove();
|
2025-10-17 23:54:45 +02:00
|
|
|
if ($streetViewEnabled) {
|
2025-06-21 21:07:36 +02:00
|
|
|
mapillaryLayer?.add();
|
|
|
|
|
} else {
|
|
|
|
|
mapillaryLayer?.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mapillaryLayer?.remove();
|
2025-10-17 23:54:45 +02:00
|
|
|
if ($streetViewEnabled) {
|
2025-06-21 21:07:36 +02:00
|
|
|
googleRedirect?.add();
|
|
|
|
|
} else {
|
|
|
|
|
googleRedirect?.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<CustomControl class="w-[29px] h-[29px] shrink-0">
|
|
|
|
|
<Tooltip class="w-full h-full" side="left" label={i18n._('menu.toggle_street_view')}>
|
|
|
|
|
<Toggle
|
2025-10-17 23:54:45 +02:00
|
|
|
bind:pressed={$streetViewEnabled}
|
2025-06-21 21:07:36 +02:00
|
|
|
class="w-full h-full rounded p-0"
|
|
|
|
|
aria-label={i18n._('menu.toggle_street_view')}
|
|
|
|
|
>
|
|
|
|
|
<PersonStanding size="22" />
|
|
|
|
|
</Toggle>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</CustomControl>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
bind:this={container}
|
|
|
|
|
class="{mapillaryOpen.value
|
|
|
|
|
? ''
|
|
|
|
|
: 'hidden'} !absolute bottom-[44px] right-2.5 z-10 w-[40%] h-[40%] bg-background rounded-md overflow-hidden border-background border-2"
|
|
|
|
|
>
|
|
|
|
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
|
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
|
|
|
<div
|
|
|
|
|
class="absolute top-0 right-0 z-10 bg-background p-1 rounded-bl-md cursor-pointer"
|
|
|
|
|
onclick={() => {
|
|
|
|
|
if (mapillaryLayer) {
|
|
|
|
|
mapillaryLayer.closePopup();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<X size="16" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|