diff --git a/src/Models/MapProperties.ts b/src/Models/MapProperties.ts index c83a485ee..08580e4e3 100644 --- a/src/Models/MapProperties.ts +++ b/src/Models/MapProperties.ts @@ -17,5 +17,9 @@ export interface MapProperties { } export interface ExportableMap { - exportAsPng(dpiFactor: number): Promise + /** + * Export the current map as PNG. + * @param markerScale: if given, the markers will be 'markerScale' bigger. This is to use in combination with a supersized canvas to have more pixels and achieve print quality + */ + exportAsPng(markerScale?: number): Promise } diff --git a/src/UI/Map/MapLibreAdaptor.ts b/src/UI/Map/MapLibreAdaptor.ts index 73e7dc0d2..34735c4ca 100644 --- a/src/UI/Map/MapLibreAdaptor.ts +++ b/src/UI/Map/MapLibreAdaptor.ts @@ -224,7 +224,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap { return url } - public async exportAsPng(dpiFactor: number): Promise { + public async exportAsPng(markerScale: number = 1): Promise { const map = this._maplibreMap.data if (!map) { return undefined @@ -235,14 +235,14 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap { const ctx = drawOn.getContext("2d") // Set up CSS size. - MapLibreAdaptor.setDpi(drawOn, ctx, dpiFactor / map.getPixelRatio()) + MapLibreAdaptor.setDpi(drawOn, ctx, markerScale / map.getPixelRatio()) await this.exportBackgroundOnCanvas(ctx) // MapLibreAdaptor.setDpi(drawOn, ctx, 1) - const markers = await this.drawMarkers(dpiFactor) + const markers = await this.drawMarkers(markerScale) ctx.drawImage(markers, 0, 0, drawOn.width, drawOn.height) - ctx.scale(dpiFactor, dpiFactor) + ctx.scale(markerScale, markerScale) this._maplibreMap.data?.resize() return await new Promise((resolve) => drawOn.toBlob((blob) => resolve(blob))) }