From 1730d1c1114291c3dad0aaaf28ced977fd9fefe0 Mon Sep 17 00:00:00 2001 From: Cfp Date: Mon, 11 Aug 2025 09:12:44 +0200 Subject: [PATCH] fix(offlinetiles): wrong fetching of local tiles --- src/lib/services/OfflineTiles.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/services/OfflineTiles.ts b/src/lib/services/OfflineTiles.ts index a973cf8..dc10d4c 100644 --- a/src/lib/services/OfflineTiles.ts +++ b/src/lib/services/OfflineTiles.ts @@ -30,8 +30,10 @@ export async function downloadPMTiles(url: string, name: string): Promise const path = await join(appDataDirPath, filename); + let totalProgress = 0; await download(url, path, ({ progress, total }) => { - console.log(`Download progress: ${Math.round((progress / total) * 100)}% (${progress}\tof ${total} bytes)`); + totalProgress += progress; + console.log(`Download progress: ${Math.round((totalProgress / total) * 100)}% (${totalProgress}\tof ${total} bytes)`); }); console.log(`Download completed: ${path}`); @@ -123,8 +125,7 @@ interface RequestParameters { export class Protocol { /** @hidden */ tiles: Map; - metadata: boolean; - errorOnMissingTile: boolean; + metadata: boolean; errorOnMissingTile: boolean; /** * Initialize the MapLibre PMTiles protocol. @@ -203,7 +204,7 @@ export class Protocol { let instance = this.tiles.get(pmtilesUrl); if (!instance) { - instance = new PMTiles(pmtilesUrl); + instance = new PMTiles(new FSSource(pmtilesUrl)); this.tiles.set(pmtilesUrl, instance); } const z = result[2];