2021-01-04 04:06:21 +01:00
|
|
|
import {DropDown} from "../Input/DropDown";
|
|
|
|
import Translations from "../i18n/Translations";
|
|
|
|
import State from "../../State";
|
2021-01-04 04:36:21 +01:00
|
|
|
import BaseLayer from "../../Models/BaseLayer";
|
2021-06-12 02:58:32 +02:00
|
|
|
import {VariableUiElement} from "../Base/VariableUIElement";
|
2020-09-25 21:58:29 +02:00
|
|
|
|
2021-06-12 02:58:32 +02:00
|
|
|
export default class BackgroundSelector extends VariableUiElement {
|
2020-09-25 21:58:29 +02:00
|
|
|
|
2020-09-28 00:30:39 +02:00
|
|
|
constructor() {
|
2021-06-12 02:58:32 +02:00
|
|
|
const available = State.state.availableBackgroundLayers.map(available => {
|
|
|
|
const baseLayers: { value: BaseLayer, shown: string }[] = [];
|
|
|
|
for (const i in available) {
|
2021-09-09 00:05:51 +02:00
|
|
|
if (!available.hasOwnProperty(i)) {
|
2021-06-12 02:58:32 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const layer: BaseLayer = available[i];
|
|
|
|
baseLayers.push({value: layer, shown: layer.name ?? "id:" + layer.id});
|
|
|
|
}
|
|
|
|
return baseLayers
|
|
|
|
}
|
|
|
|
)
|
2020-09-25 21:58:29 +02:00
|
|
|
|
2021-06-12 02:58:32 +02:00
|
|
|
super(
|
|
|
|
available.map(baseLayers => {
|
|
|
|
if (baseLayers.length <= 1) {
|
|
|
|
return undefined;
|
|
|
|
}
|
2021-06-14 17:42:26 +02:00
|
|
|
return new DropDown(Translations.t.general.backgroundMap.Clone(), baseLayers, State.state.backgroundLayer)
|
2021-06-12 02:58:32 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
2020-09-25 21:58:29 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|