| 
									
										
										
										
											2022-09-08 21:40:48 +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" | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-11 14:55:25 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * The icon with the 'plus'-sign and the preset icons spinning | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-06-11 14:55:25 +02:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  | export default class AddNewMarker extends Combine { | 
					
						
							|  |  |  |     constructor(filteredLayers: UIEventSource<FilteredLayer[]>) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const icons = new VariableUiElement( | 
					
						
							|  |  |  |             filteredLayers.map((filteredLayers) => { | 
					
						
							|  |  |  |                 const icons = [] | 
					
						
							|  |  |  |                 let last = undefined | 
					
						
							|  |  |  |                 for (const filteredLayer of filteredLayers) { | 
					
						
							|  |  |  |                     const layer = filteredLayer.layerDef | 
					
						
							|  |  |  |                     if (layer.name === undefined && !filteredLayer.isDisplayed.data) { | 
					
						
							|  |  |  |                         continue | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     for (const preset of filteredLayer.layerDef.presets) { | 
					
						
							|  |  |  |                         const tags = TagUtils.KVtoProperties(preset.tags) | 
					
						
							|  |  |  |                         const icon = layer.mapRendering[0] | 
					
						
							| 
									
										
										
										
											2023-03-14 00:31:44 +01:00
										 |  |  |                             .GenerateLeafletStyle(new UIEventSource<any>(tags), false, { | 
					
						
							|  |  |  |                                 noSize: true, | 
					
						
							|  |  |  |                             }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                             .html.SetClass("block relative") | 
					
						
							|  |  |  |                             .SetStyle("width: 42px; height: 42px;") | 
					
						
							|  |  |  |                         icons.push(icon) | 
					
						
							|  |  |  |                         if (last === undefined) { | 
					
						
							|  |  |  |                             last = layer.mapRendering[0] | 
					
						
							| 
									
										
										
										
											2023-03-14 00:31:44 +01:00
										 |  |  |                                 .GenerateLeafletStyle(new UIEventSource<any>(tags), false, { | 
					
						
							|  |  |  |                                     noSize: true, | 
					
						
							|  |  |  |                                 }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                                 .html.SetClass("block relative") | 
					
						
							|  |  |  |                                 .SetStyle("width: 42px; height: 42px;") | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 if (icons.length === 0) { | 
					
						
							|  |  |  |                     return undefined | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (icons.length === 1) { | 
					
						
							|  |  |  |                     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" | 
					
						
							|  |  |  |             ) | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |             .SetStyle("top: 65px; transform: translateX(-50%)") | 
					
						
							|  |  |  |         super([ | 
					
						
							|  |  |  |             new Combine([ | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 Svg.add_pin_svg() | 
					
						
							|  |  |  |                     .SetClass("absolute") | 
					
						
							|  |  |  |                     .SetStyle("width: 50px; filter: drop-shadow(grey 0 0 10px"), | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |                 new Combine([icons]) | 
					
						
							|  |  |  |                     .SetStyle("width: 50px") | 
					
						
							|  |  |  |                     .SetClass("absolute p-1 rounded-full overflow-hidden"), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 Svg.addSmall_svg() | 
					
						
							|  |  |  |                     .SetClass("absolute animate-pulse") | 
					
						
							|  |  |  |                     .SetStyle("width: 30px; left: 30px; top: 35px;"), | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |             ]).SetClass("absolute"), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             new Combine([label]).SetStyle("position: absolute; left: 50%"), | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.SetClass("block relative") | 
					
						
							| 
									
										
										
										
											2021-08-22 18:48:38 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |