Skip to content

Commit

Permalink
Merge pull request #1301 from swisstopo/GSNGM-1162_kml_ordering
Browse files Browse the repository at this point in the history
Ordering for uploaded KMLs
  • Loading branch information
vladyslav-tk authored Jun 12, 2024
2 parents 697faaf + fdd3cee commit ba61e9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ui/src/elements/ngm-side-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,9 @@ export class SideBar extends LitElementI18n {
if (!this.viewer) return;
const dataSource = new CustomDataSource();
const name = await parseKml(this.viewer, file, dataSource, clampToGround);
const layer = `${name.replace(' ', '_')}_${Date.now()}`;
// name used as id for datasource
dataSource.name = `${name}_${Date.now()}`;
dataSource.name = layer;
MainStore.addUploadedKmlName(dataSource.name);
await this.viewer.dataSources.add(dataSource);
await renderWithDelay(this.viewer);
Expand All @@ -757,6 +758,7 @@ export class SideBar extends LitElementI18n {
const config: LayerConfig = {
load() {return promise;},
label: name,
layer,
promise: promise,
zoomToBbox: true,
opacity: DEFAULT_LAYER_OPACITY,
Expand Down
9 changes: 6 additions & 3 deletions ui/src/layers/LayersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ export default class LayersAction {

async reorderLayers(newLayers: LayerConfig[]) {
const imageries = this.viewer.scene.imageryLayers;
const dataSources = this.viewer.dataSources;
for (const config of newLayers) {
if (config.type === LayerType.swisstopoWMTS) {
const imagery = await config.promise;
if (imagery instanceof ImageryLayer) imageries.raiseToTop(imagery);
const layer = await config.promise;
if (config.type === LayerType.swisstopoWMTS && layer instanceof ImageryLayer) {
imageries.raiseToTop(layer);
} else if (layer instanceof CustomDataSource && dataSources.contains(layer)) {
dataSources.raiseToTop(layer);
}
}
syncLayersParam(newLayers);
Expand Down

0 comments on commit ba61e9a

Please sign in to comment.