From b992e3da8bfdd3386a991fd08ee9f506e1002041 Mon Sep 17 00:00:00 2001 From: AlitaBernachot Date: Mon, 6 Jan 2025 12:25:21 +0100 Subject: [PATCH] feat: add tms support for basemap --- conf/default.toml | 7 +++++-- libs/util/app-config/src/lib/app-config.spec.ts | 12 +++++++++++- libs/util/app-config/src/lib/app-config.ts | 4 +++- libs/util/app-config/src/lib/map-layers.ts | 6 ++++++ libs/util/app-config/src/lib/model.ts | 4 +++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/conf/default.toml b/conf/default.toml index 2586bd0866..33205c3079 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -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 @@ -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'. @@ -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" diff --git a/libs/util/app-config/src/lib/app-config.spec.ts b/libs/util/app-config/src/lib/app-config.spec.ts index 53b05d6bfa..63c400e4b9 100644 --- a/libs/util/app-config/src/lib/app-config.spec.ts +++ b/libs/util/app-config/src/lib/app-config.spec.ts @@ -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() }) @@ -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', + }, ], }) }) diff --git a/libs/util/app-config/src/lib/app-config.ts b/libs/util/app-config/src/lib/app-config.ts index 5547fd1653..6a459cd972 100644 --- a/libs/util/app-config/src/lib/app-config.ts +++ b/libs/util/app-config/src/lib/app-config.ts @@ -137,7 +137,7 @@ export function loadAppConfig() { parsed, 'map_layer', ['type'], - ['name', 'url', 'data'], + ['name', 'url', 'data', 'styleUrl', 'accessToken'], warnings, errors ) @@ -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) diff --git a/libs/util/app-config/src/lib/map-layers.ts b/libs/util/app-config/src/lib/map-layers.ts index 8f6e75ddc8..e5b42cf2f3 100644 --- a/libs/util/app-config/src/lib/map-layers.ts +++ b/libs/util/app-config/src/lib/map-layers.ts @@ -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, + } } } diff --git a/libs/util/app-config/src/lib/model.ts b/libs/util/app-config/src/lib/model.ts index 072dadd2b6..42098acc61 100644 --- a/libs/util/app-config/src/lib/model.ts +++ b/libs/util/app-config/src/lib/model.ts @@ -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 {