Skip to content

Commit

Permalink
feat: add tms support for basemap
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Jan 6, 2025
1 parent d9a09c3 commit b992e3d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
7 changes: 5 additions & 2 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ proxy_path = ""
[theme]
primary_color = "#c82850"
secondary_color = "#001638"
main_color = "#555" # All-purpose text color
main_color = "#555" # All-purpose text color
background_color = "#fdfbff"

# These optional parameters indicate which background should be used for the main header and the text color used
Expand Down Expand Up @@ -149,7 +149,7 @@ background_color = "#fdfbff"

# Optional; if true, the default basemap will not be added to the map.
# Use [[map_layer]] sections to define your own custom layers (see below)
# do_not_use_default_basemap = false
do_not_use_default_basemap = true

# One or several layers (as background or overlay) can be added to the map with the following properties:
# - type (mandatory): Indicates the layer type. Possible values are 'xyz', 'wms', 'wfs', 'geojson'.
Expand All @@ -159,6 +159,9 @@ background_color = "#fdfbff"
# Layer order in the config is the same as in the map, the first one being the bottom one.
# Each layer is defined in its own [[map_layer]] section.
# Example:
[[map_layer]]
type = "maplibre-style"
styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json"
# [[map_layer]]
# type = "xyz"
# url = "https://{a-c}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"
Expand Down
12 changes: 11 additions & 1 deletion libs/util/app-config/src/lib/app-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ describe('app config utils', () => {
[[map_layer]]
type = "wfs"
url = "https://www.geo2france.fr/geoserver/cr_hdf/ows"
name = "masque_hdf_ign_carto_latin1"`
name = "masque_hdf_ign_carto_latin1"
[[map_layer]]
type = "maplibre-style"
styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json"
accessToken = "any_token"`
)
await loadAppConfig()
})
Expand All @@ -303,6 +307,12 @@ describe('app config utils', () => {
URL: 'https://www.geo2france.fr/geoserver/cr_hdf/ows',
NAME: 'masque_hdf_ign_carto_latin1',
},
{
TYPE: 'maplibre-style',
STYLE_URL:
'https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/standard.json',
ACCESS_TOKEN: 'any_token',
},
],
})
})
Expand Down
4 changes: 3 additions & 1 deletion libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function loadAppConfig() {
parsed,
'map_layer',
['type'],
['name', 'url', 'data'],
['name', 'url', 'data', 'styleUrl', 'accessToken'],
warnings,
errors
)
Expand Down Expand Up @@ -177,6 +177,8 @@ export function loadAppConfig() {
URL: map_layer.url,
NAME: map_layer.name,
DATA: map_layer.data,
STYLE_URL: map_layer.styleUrl,
ACCESS_TOKEN: map_layer.accessToken,
} as LayerConfig)
),
} as MapConfig)
Expand Down
6 changes: 6 additions & 0 deletions libs/util/app-config/src/lib/map-layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ export function getMapContextLayerFromConfig(
type: config.TYPE,
...(config.DATA ? { data: config.DATA } : { url: config.URL }),
}
case 'maplibre-style':
return {
type: config.TYPE,
styleUrl: config.STYLE_URL,
accessToken: config.ACCESS_TOKEN,
}
}
}
4 changes: 3 additions & 1 deletion libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export interface GlobalConfig {
}

export interface LayerConfig {
TYPE: 'xyz' | 'wms' | 'wfs' | 'geojson'
TYPE: 'xyz' | 'wms' | 'wfs' | 'geojson' | 'maplibre-style'
URL?: string
NAME?: string
DATA?: string
STYLE_URL?: string
ACCESS_TOKEN?: string
}

export interface MapConfig {
Expand Down

0 comments on commit b992e3d

Please sign in to comment.