From 8bdad5e6be3abb3e3a23d1c0227f03f1b33a575e Mon Sep 17 00:00:00 2001 From: AlitaBernachot Date: Mon, 6 Jan 2025 12:25:21 +0100 Subject: [PATCH 1/2] feat: add tms support for basemap --- conf/default.toml | 3 +++ 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, 26 insertions(+), 3 deletions(-) diff --git a/conf/default.toml b/conf/default.toml index 2586bd0866..286206d82b 100644 --- a/conf/default.toml +++ b/conf/default.toml @@ -160,6 +160,9 @@ background_color = "#fdfbff" # 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" # [[map_layer]] 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 { From 4f88923e615b38dfc63b3d94b304bead2439560a Mon Sep 17 00:00:00 2001 From: AlitaBernachot Date: Mon, 6 Jan 2025 15:17:47 +0100 Subject: [PATCH 2/2] doc: basemap with maplibre-style (tms support) --- docs/guide/configure.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/guide/configure.md b/docs/guide/configure.md index 61cce7aa89..5bc353bc34 100644 --- a/docs/guide/configure.md +++ b/docs/guide/configure.md @@ -231,6 +231,8 @@ The map section lets you customize how maps appear and behave across GeoNetwork- - `url` (mandatory for "xyz", "wms" and "wfs" types): Layer endpoint URL. - `name` (mandatory for "wms" and "wfs" types): indicates the layer name or feature type. - `data` (for "geojson" type only): inline GeoJSON data as string. + - `styleUrl` (mandatory for "maplibre-style" type only): Maplibre style URL. + - `accessToken` (optional for "maplibre-style" type only): credential to access the basemap styles service Layer order in the config is the same as in the map, the foreground layer being the last defined one. @@ -254,6 +256,11 @@ The map section lets you customize how maps appear and behave across GeoNetwork- "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [125.6, 10.1]}}] } """ + + [[map_layer]] + type = "maplibre-style" + styleUrl = "https://data.geopf.fr/annexes/ressources/vectorTiles/styles/PLAN.IGN/gris.json" + accessToken = "token_if_needed" # optional ``` - `external_viewer_url_template` (optional)