From c90f1de3e056640389aa0c2cb61fae032874baaa Mon Sep 17 00:00:00 2001 From: Alessandro Kreslin Date: Wed, 26 Aug 2026 11:31:31 -0400 Subject: [PATCH 1/2] Carto api key added + attribution --- src/app/Theme.ts | 20 ++++++++++++++++---- src/app/components/GtfsVisualizationMap.tsx | 3 +-- src/app/components/Map.tsx | 3 +-- src/app/components/MapGeoJSON.tsx | 3 +-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/app/Theme.ts b/src/app/Theme.ts index 6dd615f2..47fa140a 100644 --- a/src/app/Theme.ts +++ b/src/app/Theme.ts @@ -113,6 +113,18 @@ const darkPalette = { boxShadow: '0px 1px 4px 2px rgba(0,0,0,0.6)', }; +const CARTO_MAP_API_KEY = process.env['NEXT_PUBLIC_CARTO_MAP_API_KEY'] ?? ''; + +const buildBasemapTileUrl = (style: 'light_all' | 'dark_all'): string => { + const baseUrl = `https://a.basemaps.cartocdn.com/${style}/{z}/{x}/{y}{r}.png`; + return CARTO_MAP_API_KEY.length > 0 + ? `${baseUrl}?key=${CARTO_MAP_API_KEY}` + : baseUrl; +}; + +const basemapAttribution = + '© OpenStreetMap contributors © CARTO'; + /** * Map configuration per color scheme. * Extracted from the theme because map tile URLs and canvas colors @@ -121,8 +133,8 @@ const darkPalette = { */ export const mapConfig = { light: { - basemapTileUrl: - 'https://a.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', + basemapTileUrl: buildBasemapTileUrl('light_all'), + basemapAttribution, basemapTileOverallColor: '#f6f6f6', routeColor: lightPalette.background.default, routeTextColor: lightPalette.text.primary, @@ -131,8 +143,8 @@ export const mapConfig = { primaryMain: lightPalette.primary.main, }, dark: { - basemapTileUrl: - 'https://a.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', + basemapTileUrl: buildBasemapTileUrl('dark_all'), + basemapAttribution, basemapTileOverallColor: '#0d0d0d', routeColor: darkPalette.background.default, routeTextColor: darkPalette.text.primary, diff --git a/src/app/components/GtfsVisualizationMap.tsx b/src/app/components/GtfsVisualizationMap.tsx index d9f0ac45..d7752c05 100644 --- a/src/app/components/GtfsVisualizationMap.tsx +++ b/src/app/components/GtfsVisualizationMap.tsx @@ -568,8 +568,7 @@ export const GtfsVisualizationMap = ({ type: 'raster', tiles: [mapCfg.basemapTileUrl], tileSize: 256, - attribution: - '© OpenStreetMap contributors', + attribution: mapCfg.basemapAttribution, }, sample: { type: 'vector', diff --git a/src/app/components/Map.tsx b/src/app/components/Map.tsx index 8e8b98a8..2d341e88 100644 --- a/src/app/components/Map.tsx +++ b/src/app/components/Map.tsx @@ -63,8 +63,7 @@ export const Map = ( type: 'raster', tiles: [mapCfg.basemapTileUrl], tileSize: 256, - attribution: - '© OpenStreetMap contributors', + attribution: mapCfg.basemapAttribution, }, }, layers: [ diff --git a/src/app/components/MapGeoJSON.tsx b/src/app/components/MapGeoJSON.tsx index 4d8aaf42..a4bb03a7 100644 --- a/src/app/components/MapGeoJSON.tsx +++ b/src/app/components/MapGeoJSON.tsx @@ -94,8 +94,7 @@ export const MapGeoJSON = ( type: 'raster', tiles: [mapCfg.basemapTileUrl], tileSize: 256, - attribution: - '© OpenStreetMap contributors', + attribution: mapCfg.basemapAttribution, }, }, layers: [ From 2d87808c92ef13ad4fb982ca0e5f08f08b737974 Mon Sep 17 00:00:00 2001 From: Alessandro Kreslin Date: Wed, 26 Aug 2026 11:36:35 -0400 Subject: [PATCH 2/2] dot notation --- src/app/Theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Theme.ts b/src/app/Theme.ts index 47fa140a..53ace06f 100644 --- a/src/app/Theme.ts +++ b/src/app/Theme.ts @@ -113,7 +113,7 @@ const darkPalette = { boxShadow: '0px 1px 4px 2px rgba(0,0,0,0.6)', }; -const CARTO_MAP_API_KEY = process.env['NEXT_PUBLIC_CARTO_MAP_API_KEY'] ?? ''; +const CARTO_MAP_API_KEY = process.env.NEXT_PUBLIC_CARTO_MAP_API_KEY ?? ''; const buildBasemapTileUrl = (style: 'light_all' | 'dark_all'): string => { const baseUrl = `https://a.basemaps.cartocdn.com/${style}/{z}/{x}/{y}{r}.png`;