The above preview is in testmode. Changes will not be sent to OSM, so feel free to add points and answer questions
', + ); + }); + this.ListenTo(this.currentPreview); + + + this.otherPreviews = new VariableUiElement(this.url.map(url => { + + return [ + `The above preview is in testmode. Changes will not be sent to OSM, so feel free to add points and answer questions
', - `A layer is a collection of related objects which have the same or very similar tags renderings. In general, all objects of one layer have the same icon (or at least very similar icons)
"), + + createFieldUI("Name", "id", layerConfig, {description: "The name of this layer"}), + createFieldUI("A description of objects for this layer", "description", layerConfig, {description: "The description of this layer"}), + createFieldUI("Minimum zoom level", "minzoom", layerConfig, { + type: "nat", + deflt: "12", + description: "The minimum zoom level to start loading data. This is mainly limited by the expected number of objects: if there are a lot of objects, then pick something higher. A generous bounding box is put around the map, so some scrolling should be possible" + }), + createFieldUI("The tags to load from overpass", "overpassTags", layerConfig, { + type: "tags", + description: "Tags to load from overpass. The format is key=value&key0=value0&key1=value1, e.g. amenity=public_bookcase or amenity=compressed_air&bicycle=yes. Note that a wildcard is supported, e.g. key=*" + }), + + + new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.title ?? { + key: "", + addExtraTags: "", + mappings: [], + question: "", + render: "Title", + type: "string" + }, { + header: "Title element", + description: "This element is shown in the title of the popup in a header-tag", + removable: false, + hideQuestion: true + }), + + + new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.icon ?? { + key: "*", + addExtraTags: "", + mappings: [], + question: "", + render: "Title", + type: "text" + }, { + header: "Icon", + description: "This decides which icon is used to represent an element on the map. Leave blank if you don't want icons to pop up", + removable: false, + hideQuestion: true + }), + + new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.color ?? { + key: "*", + addExtraTags: "", + mappings: [], + question: "", + render: "Title", + type: "text" + }, { + header: "Colour", + description: "This decides which color is used to represent a way on the map. Note that if an icon is defined as well, the icon will be showed too", + removable: false, + hideQuestion: true + }), + + + ...layerConfig.tagRenderings.map(tr => new TagRenderingGenerator(fullConfig, layerConfig, tr, { + header: "Tag rendering", + description: "A single tag rendering", + removable: true, + hideQuestion: false + })), + new Button("Add a tag rendering", () => { + layerConfig.tagRenderings.push({ + key: undefined, + addExtraTags: undefined, + mappings: [], + question: undefined, + render: undefined, + type: "text" + }); + self.CreateElements(fullConfig, layerConfig); + self.Update(); + }), + + ...layerConfig.presets.map(preset => new PresetGenerator(fullConfig, layerConfig, preset)), new Button("Add a preset", () => { layerConfig.presets.push({ @@ -217,28 +345,7 @@ class LayerGenerator extends UIElement { }); self.CreateElements(fullConfig, layerConfig); self.Update(); - }), - new TagRenderingGenerator(fullConfig, layerConfig, layerConfig.title ?? { - key: "", - addExtraTags: "", - mappings: [], - question: "", - render: "Title", - type: "text" - }, true), - ...layerConfig.tagRenderings.map(tr => new TagRenderingGenerator(fullConfig, layerConfig, tr)), - new Button("Add a tag rendering", () => { - layerConfig.tagRenderings.push({ - key: "", - addExtraTags: "", - mappings: [], - question: "", - render: "", - type: "text" - }); - self.CreateElements(fullConfig, layerConfig); - self.Update(); - }), + }) ] } @@ -274,8 +381,12 @@ class AllLayerComponent extends UIElement { const layerPanes: { header: UIElement | string, content: UIElement | string }[] = []; const config = this.config; for (const layer of this.config.data.layers) { + + const iconUrl = CustomLayoutFromJSON.TagRenderingFromJson(layer?.icon) + .GetContent({id: "node/-1"}); const header = this.config.map(() => { - return `` + + return `` }); layerPanes.push({ header: new VariableUiElement(header), @@ -290,10 +401,17 @@ class AllLayerComponent extends UIElement { config.data.layers.push({ id: "", title: { - render: "Title" + key: "", + render: "title" + }, + icon: { + key: "", + render: "./assets/bug.svg" + }, + color: { + key: "", + render: "#0000ff" }, - icon: "./assets/bug.svg", - color: "", description: "", minzoom: 12, overpassTags: "", @@ -333,38 +451,118 @@ export class ThemeGenerator extends UIElement { if (windowHash !== undefined && windowHash.length > 4) { loadedTheme = JSON.parse(atob(windowHash)); } + this.themeObject = new UIEventSource