diff --git a/CHANGELOG.md b/CHANGELOG.md index be8bb7d8..055d7d2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Fix workaround that tried to get beforeId after layer was removed. Now use workaround only if `map.getTerrain()` is not not null. - Fix set `layout.visibility` in style of `VectorLayer` based on `VectorLayer.visible`. - Fix set `VectorLayer.attribution` from `VectorLayer.options.style` for TMS. + - Fix set subdomains from `VectorLayer` in `VectorLayer.options.style` for TMS. * **@dlr-eoc/map-cesium:** - Fix get entity.name for infoBox in none GeoJson layers diff --git a/projects/map-maplibre/src/lib/maplibre-layers.helpers.ts b/projects/map-maplibre/src/lib/maplibre-layers.helpers.ts index 5c8bcd52..7623aaa5 100644 --- a/projects/map-maplibre/src/lib/maplibre-layers.helpers.ts +++ b/projects/map-maplibre/src/lib/maplibre-layers.helpers.ts @@ -172,6 +172,9 @@ export function createTmsLayer(l: T if (!(source as any).attribution && l.attribution) { (source as any).attribution = l.attribution; } + if (key === sourceKey) { + setSubdomains(l,source); + } }); style.layers.forEach(ls => { (ls.metadata as any) = Object.assign(ls.metadata as any || {}, addUkisLayerMetadata(l)) @@ -191,6 +194,19 @@ export function createTmsLayer(l: T return layerSourceOrStyleSpecification; } +/** use subdomains to setUrl/s on source */ +function setSubdomains(l: ukisLayer, source: SourceSpecification): void { + if (l instanceof ukisVectorLayer || l instanceof ukisRasterLayer) { + if (l.subdomains && source.type === 'vector' || source.type === 'raster' || source.type === 'raster-dem') { + if (l.type === 'wfs' && l instanceof ukisVectorLayer) { + source.tiles = [l.url.replace('{s}', `${l.subdomains[0]}-${l.subdomains[l.subdomains.length - 1]}`)]; + } else { + const urls = l.subdomains.map((item) => l.url.replace('{s}', `${item}`)); + source.tiles = urls; + } + } + } +} export function createGeojsonLayer(l: ukisVectorLayer) { const { source } = createBaseLayer(l)