From 0a104cc0ed59671f4b1d340e06082b88ad79ec7c Mon Sep 17 00:00:00 2001 From: Drew Slobodnjak <60050885+drew08t@users.noreply.github.com> Date: Thu, 29 May 2025 12:09:41 -0700 Subject: [PATCH] Geomap: Add HiDPI support to CARTO basemap (#81195) (#106211) Co-authored-by: Cledwyn Lew --- public/app/plugins/panel/geomap/layers/basemaps/carto.ts | 3 ++- public/app/plugins/panel/geomap/utils/utils.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/geomap/layers/basemaps/carto.ts b/public/app/plugins/panel/geomap/layers/basemaps/carto.ts index 1d1082e141f..45f65b2b267 100644 --- a/public/app/plugins/panel/geomap/layers/basemaps/carto.ts +++ b/public/app/plugins/panel/geomap/layers/basemaps/carto.ts @@ -45,10 +45,11 @@ export const carto: MapLayerRegistryItem = { } else { style += '_nolabels'; } + const scale = window.devicePixelRatio > 1 ? '@2x' : ''; return new TileLayer({ source: new XYZ({ attributions: `©CARTO ©OpenStreetMap contributors`, - url: `https://{1-4}.basemaps.cartocdn.com/${style}/{z}/{x}/{y}.png`, + url: `https://{1-4}.basemaps.cartocdn.com/${style}/{z}/{x}/{y}${scale}.png`, }), }); }, diff --git a/public/app/plugins/panel/geomap/utils/utils.ts b/public/app/plugins/panel/geomap/utils/utils.ts index 0e14164b413..23426d54db4 100644 --- a/public/app/plugins/panel/geomap/utils/utils.ts +++ b/public/app/plugins/panel/geomap/utils/utils.ts @@ -99,7 +99,7 @@ export const getNewOpenLayersMap = (panel: GeomapPanel, options: Options, div: H const view = panel.initMapView(options.view); return (panel.map = new OpenLayersMap({ view: view, - pixelRatio: 1, // or zoom? + pixelRatio: window.devicePixelRatio, // or zoom? layers: [], // loaded explicitly below controls: [], target: div,