From 9f5afa4b940f55285df994f8c4cbe7a49a7a4c42 Mon Sep 17 00:00:00 2001 From: Russ Garrett Date: Fri, 17 May 2024 01:17:14 +0100 Subject: [PATCH] Make icons work in export function --- web/src/export/export.ts | 8 ++++++++ web/src/index.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/src/export/export.ts b/web/src/export/export.ts index 0a28d67..d77675c 100644 --- a/web/src/export/export.ts +++ b/web/src/export/export.ts @@ -10,6 +10,11 @@ class ExportControl implements maplibregl.IControl { _map?: maplibregl.Map exportZoom: number = 18 pixelRatio: number = 4 + initFunc?: (map: maplibregl.Map) => void + + constructor(initFunc?: (map: maplibregl.Map) => void) { + this.initFunc = initFunc + } doExport() { const srcContainer = this._map!._container @@ -49,6 +54,9 @@ class ExportControl implements maplibregl.IControl { fadeDuration: 0, attributionControl: false, }) + if (this.initFunc) { + this.initFunc(renderMap) + } renderMap.once('idle', () => { const canvas = renderMap.getCanvas() diff --git a/web/src/index.ts b/web/src/index.ts index 513cdb9..62686a6 100644 --- a/web/src/index.ts +++ b/web/src/index.ts @@ -111,7 +111,7 @@ class EventMap { // Display edit control only on browsers which are likely to be desktop browsers if (window.matchMedia('(min-width: 600px)').matches) { - this.map.addControl(new ExportControl(), 'top-right') + this.map.addControl(new ExportControl(loadIcons), 'top-right') } this.map.addControl(this.layer_switcher, 'top-right')