From f197756bb45382b1b3b38148750da1df2fedff48 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 15 Feb 2026 21:19:19 +0200 Subject: [PATCH] feat(collections/map): proper DPI scaling of icons --- .../src/widgets/collections/geomap/marker_data.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/client/src/widgets/collections/geomap/marker_data.ts b/apps/client/src/widgets/collections/geomap/marker_data.ts index 5bf37f0291..83976709d5 100644 --- a/apps/client/src/widgets/collections/geomap/marker_data.ts +++ b/apps/client/src/widgets/collections/geomap/marker_data.ts @@ -9,10 +9,10 @@ const DEFAULT_MARKER_COLOR = "#2A81CB"; // SVG marker pin shape (replaces the Leaflet marker PNG). export const MARKER_SVG = "foo"; // TODO: Fix -async function buildMarkerIcon(color = DEFAULT_MARKER_COLOR, iconClass: string) { - const iconUrl = await snapshotIcon(iconClass); +async function buildMarkerIcon(color = DEFAULT_MARKER_COLOR, iconClass: string, scale = window.devicePixelRatio || 1) { + const iconUrl = await snapshotIcon(iconClass, 16 * scale); return `\ - + @@ -20,13 +20,13 @@ async function buildMarkerIcon(color = DEFAULT_MARKER_COLOR, iconClass: string) `; } -async function snapshotIcon(iconClass: string) { +async function snapshotIcon(iconClass: string, size: number) { await document.fonts.ready; const glyph = getGlyphFromClass(iconClass); const rendered = renderMarkerCanvas({ color: "black", glyph, - size: 16 + size }); return rendered?.toDataURL(); } @@ -144,7 +144,9 @@ export function useMarkerData(note: FNote | null | undefined, apiRef: MutableRef // Build all the icons. await Promise.all(iconSvgCache.entries().map(async ([ key, svg ]) => { const image = await svgToImage(svg); - map.addImage(key, image); + map.addImage(key, image, { + pixelRatio: window.devicePixelRatio + }); })); map.addSource("points", {