From 8ba17245bec4630f9f15007adb7446ae6f9ce08e Mon Sep 17 00:00:00 2001 From: Christopher Meyer Date: Sat, 14 Jun 2025 21:46:20 +0200 Subject: [PATCH 1/2] Updated leaflet.ts to enable custom devicePixelRatio setting Updated leaflet.ts to enable custom devicePixelRatio setting --- src/frontends/leaflet.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontends/leaflet.ts b/src/frontends/leaflet.ts index c6338f56..9476e84d 100644 --- a/src/frontends/leaflet.ts +++ b/src/frontends/leaflet.ts @@ -58,6 +58,7 @@ export interface LeafletLayerOptions extends L.GridLayerOptions { sources?: Record; flavor?: string; backgroundColor?: string; + devicePixelRatio?: number; } const leafletLayer = (options: LeafletLayerOptions = {}) => { @@ -65,6 +66,7 @@ const leafletLayer = (options: LeafletLayerOptions = {}) => { public paintRules: PaintRule[]; public labelRules: LabelRule[]; public backgroundColor?: string; + public devicePixelRatio: number; constructor(options: LeafletLayerOptions = {}) { if (options.noWrap && !options.bounds) @@ -88,6 +90,9 @@ const leafletLayer = (options: LeafletLayerOptions = {}) => { this.backgroundColor = options.backgroundColor; } + this.devicePixelRatio = options.devicePixelRatio ?? + window.devicePixelRatio; + this.lastRequestedZ = undefined; this.tasks = options.tasks || []; @@ -107,7 +112,7 @@ const leafletLayer = (options: LeafletLayerOptions = {}) => { 16, this.onTilesInvalidated, ); - this.tileSize = 256 * window.devicePixelRatio; + this.tileSize = 256 * this.devicePixelRatio; this.tileDelay = options.tileDelay || 3; this.lang = options.lang; } From 849fa9df79e552c75e70b5486cfcaf4b8bf7dbf8 Mon Sep 17 00:00:00 2001 From: Christopher Meyer Date: Sat, 14 Jun 2025 22:35:10 +0200 Subject: [PATCH 2/2] updated formatting for tests --- src/frontends/leaflet.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontends/leaflet.ts b/src/frontends/leaflet.ts index 9476e84d..10268eed 100644 --- a/src/frontends/leaflet.ts +++ b/src/frontends/leaflet.ts @@ -90,8 +90,8 @@ const leafletLayer = (options: LeafletLayerOptions = {}) => { this.backgroundColor = options.backgroundColor; } - this.devicePixelRatio = options.devicePixelRatio ?? - window.devicePixelRatio; + this.devicePixelRatio = + options.devicePixelRatio ?? window.devicePixelRatio; this.lastRequestedZ = undefined; this.tasks = options.tasks || [];