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 8bdad5e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
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 8bdad5e

Please sign in to comment.