diff --git a/src/app/Theme.ts b/src/app/Theme.ts
index 6dd615f..53ace06 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 d9f0ac4..d7752c0 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 8e8b98a..2d341e8 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 4d8aaf4..a4bb03a 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: [