2025-02-02 11:17:22 +01:00
|
|
|
import { dbUtils } from '$lib/db';
|
|
|
|
|
import { MapPopup } from '$lib/components/MapPopup';
|
2024-10-08 15:49:14 +02:00
|
|
|
|
|
|
|
|
export let waypointPopup: MapPopup | null = null;
|
|
|
|
|
export let trackpointPopup: MapPopup | null = null;
|
|
|
|
|
|
|
|
|
|
export function createPopups(map: mapboxgl.Map) {
|
|
|
|
|
removePopups();
|
|
|
|
|
waypointPopup = new MapPopup(map, {
|
|
|
|
|
closeButton: false,
|
|
|
|
|
focusAfterOpen: false,
|
|
|
|
|
maxWidth: undefined,
|
|
|
|
|
offset: {
|
2025-02-02 11:17:22 +01:00
|
|
|
top: [0, 0],
|
2024-10-08 15:49:14 +02:00
|
|
|
'top-left': [0, 0],
|
|
|
|
|
'top-right': [0, 0],
|
2025-02-02 11:17:22 +01:00
|
|
|
bottom: [0, -30],
|
2024-10-08 15:49:14 +02:00
|
|
|
'bottom-left': [0, -30],
|
|
|
|
|
'bottom-right': [0, -30],
|
2025-02-02 11:17:22 +01:00
|
|
|
left: [10, -15],
|
|
|
|
|
right: [-10, -15],
|
2024-10-08 15:49:14 +02:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
trackpointPopup = new MapPopup(map, {
|
|
|
|
|
closeButton: false,
|
|
|
|
|
focusAfterOpen: false,
|
|
|
|
|
maxWidth: undefined,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function removePopups() {
|
|
|
|
|
if (waypointPopup !== null) {
|
|
|
|
|
waypointPopup.remove();
|
|
|
|
|
waypointPopup = null;
|
|
|
|
|
}
|
|
|
|
|
if (trackpointPopup !== null) {
|
|
|
|
|
trackpointPopup.remove();
|
|
|
|
|
trackpointPopup = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function deleteWaypoint(fileId: string, waypointIndex: number) {
|
|
|
|
|
dbUtils.applyToFile(fileId, (file) => file.replaceWaypoints(waypointIndex, waypointIndex, []));
|
2025-02-02 11:17:22 +01:00
|
|
|
}
|