feat: offline tiles
Some checks failed
TrafficCue CI / build (push) Has been cancelled
TrafficCue CI / check (push) Has been cancelled

This commit is contained in:
Cfp
2025-08-09 19:02:21 +02:00
parent bece1a299c
commit 7b2df7d304
19 changed files with 3858 additions and 4177 deletions

View File

@ -8,9 +8,10 @@
routing,
} from "$lib/services/navigation/routing.svelte";
import { location } from "./location.svelte";
import { protocol } from "$lib/services/OfflineTiles";
import { saved } from "$lib/saved.svelte";
import RoutingLayers from "$lib/services/navigation/RoutingLayers.svelte";
import { protocol } from "$lib/services/OfflineTiles";
import { layers, worldLayers } from "$lib/mapLayers";
onMount(() => {
window.addEventListener("resize", map.updateMapPadding);
@ -26,7 +27,9 @@
const DEBUG_POINTS = false; // Set to true to show debug points on the map
</script>
<Protocol scheme="tiles" loadFn={protocol} />
<!-- <Protocol scheme="tiles" loadFn={protocol} /> -->
<!-- <PMTilesProtocol /> -->
<Protocol scheme="pmtiles" loadFn={protocol} />
<MapLibre
class="w-full h-full"
@ -39,6 +42,32 @@
location.locked = true;
// @ts-expect-error - not typed
window.map = map.value;
// const worldUrl = await getPMTiles("world");
// if(worldUrl) {
map.value!.addSource("ne2_shaded", { // TODO: rename to world
type: "vector",
url: "pmtiles://world",
attribution: "Natural Earth",
// maxzoom: 6
})
// @ts-expect-error - not typed correctly
worldLayers.forEach(l => map.value!.addLayer(l));
// }
// const url = await getPMTiles("tiles");
// console.log(url)
// if(url) {
map.value!.addSource("openmaptiles", {
type: "vector",
url: "pmtiles://tiles"
})
// @ts-expect-error - not typed correctly
layers.forEach(l => map.value!.addLayer(l));
// }
}}
onclick={(e) => {
if (view.current.type == "main" || view.current.type == "info") {