From f2e3173eebd1c4eabe7d424c29ea9b2f9ae0aa17 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 19 Oct 2023 13:36:49 +0200 Subject: [PATCH 1/4] Legacy: add fix for fs-userbadge --- src/Logic/State/FeatureSwitchState.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Logic/State/FeatureSwitchState.ts b/src/Logic/State/FeatureSwitchState.ts index a12835fbb1..2c1700c50d 100644 --- a/src/Logic/State/FeatureSwitchState.ts +++ b/src/Logic/State/FeatureSwitchState.ts @@ -75,6 +75,13 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches { layoutToUse?.enableUserBadge ?? true, "Disables/Enables logging in and thus disables editing all together. This effectively puts MapComplete into read-only mode." ) + { + if(QueryParameters.wasInitialized("fs-userbadge")){ + // userbadge is the legacy name for 'enable-login' + this.featureSwitchEnableLogin.setData(QueryParameters.GetBooleanQueryParameter("fs-userbadge", undefined, "Legacy").data) + } + } + this.featureSwitchSearch = FeatureSwitchUtils.initSwitch( "fs-search", layoutToUse?.enableSearch ?? true, From 2a0e194c202a63592167742d00ce8797b56b94aa Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 19 Oct 2023 16:32:42 +0200 Subject: [PATCH 2/4] Docs: update docs --- src/Models/MapProperties.ts | 6 +++++- src/UI/Map/MapLibreAdaptor.ts | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Models/MapProperties.ts b/src/Models/MapProperties.ts index c83a485ee1..08580e4e3e 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 73e7dc0d28..34735c4caf 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))) } From 94291de5a3451120b6abdb153ba57675949d3d5b Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 20 Oct 2023 12:51:40 +0200 Subject: [PATCH 3/4] Themes: enable 'guideposts' in nature theme --- assets/themes/nature/nature.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/themes/nature/nature.json b/assets/themes/nature/nature.json index a67fef8bce..1f1abe718b 100644 --- a/assets/themes/nature/nature.json +++ b/assets/themes/nature/nature.json @@ -52,11 +52,12 @@ "information_board", "bench", "picnic_table", - "toilet" + "toilet", + "guidepost" ], "override": { "minzoom": 16 } } ] -} \ No newline at end of file +} From 54868debec137c57b8dd45024332854150cc8f0f Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 20 Oct 2023 18:23:35 +0200 Subject: [PATCH 4/4] Fix: correct CSP header for iOs/safari --- scripts/generateLayouts.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/generateLayouts.ts b/scripts/generateLayouts.ts index 0763f38b99..53465995b1 100644 --- a/scripts/generateLayouts.ts +++ b/scripts/generateLayouts.ts @@ -315,18 +315,19 @@ async function generateCsp( const csp: Record = { "default-src": "'self'", - "script-src": ["'self'", "https://gc.zgo.at/count.js", ...(options?.scriptSrcs ?? [])].join( - " " - ), + "child-src": "'self' blob: ", "img-src": "* data:", // maplibre depends on 'data:' to load "connect-src": connectSrc.join(" "), "report-to": "https://report.mapcomplete.org/csp", "worker-src": "'self' blob:", // Vite somehow loads the worker via a 'blob' "style-src": "'self' 'unsafe-inline'", // unsafe-inline is needed to change the default background pin colours + "script-src": ["'self'", "https://gc.zgo.at/count.js", ...(options?.scriptSrcs ?? [])].join( + " " + ), } const content = Object.keys(csp) .map((k) => k + " " + csp[k]) - .join("; ") + .join(" ; ") return [ ``,