All files / map basemaps.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 0/0
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43          3x     3x   3x                                   3x                 3x          
import type { StyleSpecification } from 'maplibre-gl'
 
import type { MapStyle } from '../core/domain'
import type { MapTone } from '../core/systems/types'
 
const OPENFREEMAP_URL = 'https://tiles.openfreemap.org'
 
/** OpenFreeMap serves the glyphs for every base map, so grid labels can use one font on all of them. */
export const GLYPHS_URL = `${OPENFREEMAP_URL}/fonts/{fontstack}/{range}.pbf`
 
const satelliteStyle: StyleSpecification = {
  version: 8,
  glyphs: GLYPHS_URL,
  sources: {
    imagery: {
      type: 'raster',
      tiles: [
        'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
      ],
      tileSize: 256,
      maxzoom: 19,
      attribution: 'Imagery © Esri, Maxar, Earthstar Geographics',
    },
  },
  layers: [{ id: 'imagery', type: 'raster', source: 'imagery' }],
}
 
/** Which grid colours suit each base map. Satellite imagery is dark enough for the dark set. */
export const basemapTone: Record<MapStyle.Basemap, MapTone> = {
  Dark: 'onDark',
  Light: 'onLight',
  Satellite: 'onDark',
}
 
export const basemapStyles: Record<
  MapStyle.Basemap,
  string | StyleSpecification
> = {
  Dark: `${OPENFREEMAP_URL}/styles/dark`,
  Light: `${OPENFREEMAP_URL}/styles/positron`,
  Satellite: satelliteStyle,
}