Skip to content

Commit

Permalink
fix: set subdomains of tms vector layer
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckMt committed Apr 23, 2024
1 parent 70febcb commit 2937694
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions projects/map-maplibre/src/lib/maplibre-layers.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export function createTmsLayer<T extends ukisRasterLayer | ukisVectorLayer>(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))
Expand All @@ -191,6 +194,19 @@ export function createTmsLayer<T extends ukisRasterLayer | ukisVectorLayer>(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<GeoJSONSourceSpecification>(l)
Expand Down

0 comments on commit 2937694

Please sign in to comment.