forked from MapComplete/MapComplete
refactoring(maplibre): add RasterLayer info, add background switch, add default global layers
This commit is contained in:
parent
703d561324
commit
4f2bbf4b54
14 changed files with 1103 additions and 472 deletions
|
@ -1,41 +0,0 @@
|
|||
import { DropDown } from "../Input/DropDown"
|
||||
import Translations from "../i18n/Translations"
|
||||
import State from "../../State"
|
||||
import BaseLayer from "../../Models/BaseLayer"
|
||||
import { VariableUiElement } from "../Base/VariableUIElement"
|
||||
import { Store } from "../../Logic/UIEventSource"
|
||||
|
||||
export default class BackgroundSelector extends VariableUiElement {
|
||||
constructor(state: { availableBackgroundLayers?: Store<BaseLayer[]> }) {
|
||||
const available = state.availableBackgroundLayers?.map((available) => {
|
||||
if (available === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const baseLayers: { value: BaseLayer; shown: string }[] = []
|
||||
for (const i in available) {
|
||||
if (!available.hasOwnProperty(i)) {
|
||||
continue
|
||||
}
|
||||
const layer: BaseLayer = available[i]
|
||||
baseLayers.push({ value: layer, shown: layer.name ?? "id:" + layer.id })
|
||||
}
|
||||
return baseLayers
|
||||
})
|
||||
|
||||
super(
|
||||
available?.map((baseLayers) => {
|
||||
if (baseLayers === undefined || baseLayers.length <= 1) {
|
||||
return undefined
|
||||
}
|
||||
return new DropDown(
|
||||
Translations.t.general.backgroundMap.Clone(),
|
||||
baseLayers,
|
||||
State.state.backgroundLayer,
|
||||
{
|
||||
select_class: "bg-indigo-100 p-1 rounded hover:bg-indigo-200 w-full",
|
||||
}
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue