CARTO Basemaps exige une clé depuis le 23/09/2026 : sans elle, chaque tuile porte le filigrane « API KEY REQUIRED ». Clé lue au runtime (NUXT_PUBLIC_CARTO_KEY) ; sans clé, repli sur le Plan IGN (Géoplateforme). FicheDetail quitte aussi les tuiles OSM (418, politique d'usage). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
// Fond de carte commun aux cartes Leaflet.
|
||
// CARTO exige une clé depuis le 23/09/2026 (sans clé : filigrane « API KEY REQUIRED »).
|
||
// Clé fournie au runtime par NUXT_PUBLIC_CARTO_KEY ; sans clé, repli sur le Plan IGN (Géoplateforme, sans clé).
|
||
const IGN_URL = 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0'
|
||
+ '&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&STYLE=normal&TILEMATRIXSET=PM_0_19&FORMAT=image/png'
|
||
+ '&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}'
|
||
|
||
export function useBaseTiles() {
|
||
const key = useRuntimeConfig().public.cartoKey as string
|
||
|
||
function url(dark: boolean) {
|
||
if (!key) return IGN_URL
|
||
const style = dark ? 'dark_all' : 'light_all'
|
||
return `https://{s}.basemaps.cartocdn.com/${style}/{z}/{x}/{y}{r}.png?key=${encodeURIComponent(key)}`
|
||
}
|
||
|
||
const attribution = key
|
||
? '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>'
|
||
: '© <a href="https://www.ign.fr/">IGN</a> – Géoplateforme'
|
||
|
||
return { url, attribution }
|
||
}
|