Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/frontends/leaflet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ export interface LeafletLayerOptions extends L.GridLayerOptions {
sources?: Record<string, SourceOptions>;
flavor?: string;
backgroundColor?: string;
devicePixelRatio?: number;
}

const leafletLayer = (options: LeafletLayerOptions = {}) => {
class LeafletLayer extends L.GridLayer {
public paintRules: PaintRule[];
public labelRules: LabelRule[];
public backgroundColor?: string;
public devicePixelRatio: number;

constructor(options: LeafletLayerOptions = {}) {
if (options.noWrap && !options.bounds)
Expand All @@ -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 || [];

Expand All @@ -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;
}
Expand Down