2021-08-22 18:48:38 +02:00
|
|
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
|
|
|
import Combine from "../Base/Combine"
|
|
|
|
import Translations from "../i18n/Translations"
|
|
|
|
import { VariableUiElement } from "../Base/VariableUIElement"
|
|
|
|
import FilteredLayer from "../../Models/FilteredLayer"
|
|
|
|
import { TagUtils } from "../../Logic/Tags/TagUtils"
|
|
|
|
import Svg from "../../Svg"
|
|
|
|
|
2022-06-11 14:55:25 +02:00
|
|
|
/**
|
|
|
|
* The icon with the 'plus'-sign and the preset icons spinning
|
|
|
|
*
|
|
|
|
*/
|
2021-08-22 18:48:38 +02:00
|
|
|
export default class AddNewMarker extends Combine {
|
|
|
|
constructor(filteredLayers: UIEventSource<FilteredLayer[]>) {
|
|
|
|
const icons = new VariableUiElement(
|
|
|
|
filteredLayers.map((filteredLayers) => {
|
|
|
|
const icons = []
|
|
|
|
let last = undefined
|
|
|
|
for (const filteredLayer of filteredLayers) {
|
|
|
|
const layer = filteredLayer.layerDef
|
2022-04-19 00:57:36 +02:00
|
|
|
if (layer.name === undefined && !filteredLayer.isDisplayed.data) {
|
2022-02-09 03:38:40 +01:00
|
|
|
continue
|
|
|
|
}
|
2021-08-22 18:48:38 +02:00
|
|
|
for (const preset of filteredLayer.layerDef.presets) {
|
|
|
|
const tags = TagUtils.KVtoProperties(preset.tags)
|
2021-10-22 01:07:32 +02:00
|
|
|
const icon = layer.mapRendering[0]
|
|
|
|
.GenerateLeafletStyle(new UIEventSource<any>(tags), false)
|
2021-08-22 18:48:38 +02:00
|
|
|
.html.SetClass("block relative")
|
|
|
|
.SetStyle("width: 42px; height: 42px;")
|
|
|
|
icons.push(icon)
|
|
|
|
if (last === undefined) {
|
2021-10-22 01:07:32 +02:00
|
|
|
last = layer.mapRendering[0]
|
|
|
|
.GenerateLeafletStyle(new UIEventSource<any>(tags), false)
|
2021-08-22 18:48:38 +02:00
|
|
|
.html.SetClass("block relative")
|
|
|
|
.SetStyle("width: 42px; height: 42px;")
|
2022-09-08 21:40:48 +02:00
|
|
|
}
|
2021-08-22 18:48:38 +02:00
|
|
|
}
|
|
|
|
}
|
2022-01-26 21:40:38 +01:00
|
|
|
if (icons.length === 0) {
|
|
|
|
return undefined
|
2022-01-14 01:41:19 +01:00
|
|
|
}
|
2021-09-09 00:05:51 +02:00
|
|
|
if (icons.length === 1) {
|
2021-08-22 18:48:38 +02:00
|
|
|
return icons[0]
|
|
|
|
}
|
|
|
|
icons.push(last)
|
|
|
|
const elem = new Combine(icons).SetClass("flex")
|
|
|
|
elem.SetClass("slide min-w-min").SetStyle(
|
|
|
|
"animation: slide " + icons.length + "s linear infinite;"
|
|
|
|
)
|
|
|
|
return elem
|
|
|
|
})
|
|
|
|
)
|
|
|
|
const label = Translations.t.general.add.addNewMapLabel
|
|
|
|
.Clone()
|
|
|
|
.SetClass(
|
|
|
|
"block center absolute text-sm min-w-min pl-1 pr-1 bg-gray-400 rounded-3xl text-white opacity-65 whitespace-nowrap"
|
|
|
|
)
|
|
|
|
.SetStyle("top: 65px; transform: translateX(-50%)")
|
|
|
|
super([
|
|
|
|
new Combine([
|
|
|
|
Svg.add_pin_svg()
|
|
|
|
.SetClass("absolute")
|
|
|
|
.SetStyle("width: 50px; filter: drop-shadow(grey 0 0 10px"),
|
|
|
|
new Combine([icons])
|
|
|
|
.SetStyle("width: 50px")
|
|
|
|
.SetClass("absolute p-1 rounded-full overflow-hidden"),
|
|
|
|
Svg.addSmall_svg()
|
|
|
|
.SetClass("absolute animate-pulse")
|
|
|
|
.SetStyle("width: 30px; left: 30px; top: 35px;"),
|
|
|
|
]).SetClass("absolute"),
|
2021-09-09 00:05:51 +02:00
|
|
|
new Combine([label]).SetStyle("position: absolute; left: 50%"),
|
2021-08-22 18:48:38 +02:00
|
|
|
])
|
2021-09-09 00:05:51 +02:00
|
|
|
this.SetClass("block relative")
|
2021-08-22 18:48:38 +02:00
|
|
|
}
|
|
|
|
}
|