Skip to content

Commit

Permalink
Make icons work in export function
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed May 17, 2024
1 parent f8a994b commit 9f5afa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions web/src/export/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 9f5afa4

Please sign in to comment.