forked from MapComplete/MapComplete
		
	Merge master
This commit is contained in:
		
						commit
						12059bbc1a
					
				
					 5 changed files with 24 additions and 12 deletions
				
			
		|  | @ -52,7 +52,8 @@ | ||||||
|         "information_board", |         "information_board", | ||||||
|         "bench", |         "bench", | ||||||
|         "picnic_table", |         "picnic_table", | ||||||
|         "toilet" |         "toilet", | ||||||
|  |         "guidepost" | ||||||
|       ], |       ], | ||||||
|       "override": { |       "override": { | ||||||
|         "minzoom": 16 |         "minzoom": 16 | ||||||
|  |  | ||||||
|  | @ -315,19 +315,19 @@ async function generateCsp( | ||||||
| 
 | 
 | ||||||
|     const csp: Record<string, string> = { |     const csp: Record<string, string> = { | ||||||
|         "default-src": "'self'", |         "default-src": "'self'", | ||||||
|         "script-src": ["'self'", "https://gc.zgo.at/count.js", ...(options?.scriptSrcs ?? [])].join( |         "child-src": "'self' blob: ", | ||||||
|             " " |  | ||||||
|         ), |  | ||||||
|         "child-src": "self", |  | ||||||
|         "img-src": "* data:", // maplibre depends on 'data:' to load
 |         "img-src": "* data:", // maplibre depends on 'data:' to load
 | ||||||
|         "connect-src": connectSrc.join(" "), |         "connect-src": connectSrc.join(" "), | ||||||
|         "report-to": "https://report.mapcomplete.org/csp", |         "report-to": "https://report.mapcomplete.org/csp", | ||||||
|         "worker-src": "'self' blob:", // Vite somehow loads the worker via a 'blob'
 |         "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
 |         "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) |     const content = Object.keys(csp) | ||||||
|         .map((k) => k + " " + csp[k]) |         .map((k) => k + " " + csp[k]) | ||||||
|         .join("; ") |         .join(" ; ") | ||||||
| 
 | 
 | ||||||
|     return [ |     return [ | ||||||
|         `<meta http-equiv ="Report-To" content='{"group":"csp-endpoint", "max_age": 86400,"endpoints": [\{"url": "https://report.mapcomplete.org/csp"}], "include_subdomains": true}'>`, |         `<meta http-equiv ="Report-To" content='{"group":"csp-endpoint", "max_age": 86400,"endpoints": [\{"url": "https://report.mapcomplete.org/csp"}], "include_subdomains": true}'>`, | ||||||
|  |  | ||||||
|  | @ -75,6 +75,13 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches { | ||||||
|             layoutToUse?.enableUserBadge ?? true, |             layoutToUse?.enableUserBadge ?? true, | ||||||
|             "Disables/Enables logging in and thus disables editing all together. This effectively puts MapComplete into read-only mode." |             "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( |         this.featureSwitchSearch = FeatureSwitchUtils.initSwitch( | ||||||
|             "fs-search", |             "fs-search", | ||||||
|             layoutToUse?.enableSearch ?? true, |             layoutToUse?.enableSearch ?? true, | ||||||
|  |  | ||||||
|  | @ -17,5 +17,9 @@ export interface MapProperties { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface ExportableMap { | export interface ExportableMap { | ||||||
|     exportAsPng(dpiFactor: number): Promise<Blob> |     /** | ||||||
|  |      * 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<Blob> | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -224,7 +224,7 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap { | ||||||
|         return url |         return url | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public async exportAsPng(dpiFactor: number): Promise<Blob> { |     public async exportAsPng(markerScale: number = 1): Promise<Blob> { | ||||||
|         const map = this._maplibreMap.data |         const map = this._maplibreMap.data | ||||||
|         if (!map) { |         if (!map) { | ||||||
|             return undefined |             return undefined | ||||||
|  | @ -235,14 +235,14 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap { | ||||||
| 
 | 
 | ||||||
|         const ctx = drawOn.getContext("2d") |         const ctx = drawOn.getContext("2d") | ||||||
|         // Set up CSS size.
 |         // Set up CSS size.
 | ||||||
|         MapLibreAdaptor.setDpi(drawOn, ctx, dpiFactor / map.getPixelRatio()) |         MapLibreAdaptor.setDpi(drawOn, ctx, markerScale / map.getPixelRatio()) | ||||||
| 
 | 
 | ||||||
|         await this.exportBackgroundOnCanvas(ctx) |         await this.exportBackgroundOnCanvas(ctx) | ||||||
| 
 | 
 | ||||||
|         // MapLibreAdaptor.setDpi(drawOn, ctx, 1)
 |         // 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.drawImage(markers, 0, 0, drawOn.width, drawOn.height) | ||||||
|         ctx.scale(dpiFactor, dpiFactor) |         ctx.scale(markerScale, markerScale) | ||||||
|         this._maplibreMap.data?.resize() |         this._maplibreMap.data?.resize() | ||||||
|         return await new Promise<Blob>((resolve) => drawOn.toBlob((blob) => resolve(blob))) |         return await new Promise<Blob>((resolve) => drawOn.toBlob((blob) => resolve(blob))) | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue