doxa-maps-cdn/app/utils/mapProvider.ts

8 lines
551 B
TypeScript

// The map engine for every dx-maps map on this site. MapLibre (keyless) is the DEFAULT. Set
// NUXT_PUBLIC_MAP_PROVIDER=mapbox to use Mapbox, which also needs NUXT_PUBLIC_MAPBOX_TOKEN; without a token,
// even "mapbox" falls back to MapLibre, so a map always starts.
// Returns the Mapbox token to hand the maps, or '' for MapLibre.
export function mapboxTokenIfChosen(pub: Record<string, unknown>): string {
const provider = String(pub.mapProvider || 'maplibre').toLowerCase()
return provider === 'mapbox' ? String(pub.mapboxToken || '') : ''
}