diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index eb8479e7f..fba7308e9 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -69,7 +69,7 @@ export class ReferencingWaysMetaTagger extends SimpleMetaTagger { { keys: ["_referencing_ways"], isLazy: true, - doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry. ", + doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry. If the preset has 'snapToLayer' defined, the icon will be calculated based on the preset tags with `_referencing_ways=[way/-1]` added.", }, (feature, _, __, state) => { if (!ReferencingWaysMetaTagger.enabled) { diff --git a/Models/ThemeConfig/PointRenderingConfig.ts b/Models/ThemeConfig/PointRenderingConfig.ts index 8c3712f1f..8183ab032 100644 --- a/Models/ThemeConfig/PointRenderingConfig.ts +++ b/Models/ThemeConfig/PointRenderingConfig.ts @@ -5,7 +5,7 @@ import { TagUtils } from "../../Logic/Tags/TagUtils" import { Utils } from "../../Utils" import Svg from "../../Svg" import WithContextLoader from "./WithContextLoader" -import { UIEventSource } from "../../Logic/UIEventSource" +import { Store, UIEventSource } from "../../Logic/UIEventSource" import BaseUIElement from "../../UI/BaseUIElement" import { FixedUiElement } from "../../UI/Base/FixedUiElement" import Img from "../../UI/Base/Img" @@ -164,7 +164,7 @@ export default class PointRenderingConfig extends WithContextLoader { return PointRenderingConfig.FromHtmlMulti(htmlDefs, rotation, false, defaultPin) } - public GetSimpleIcon(tags: UIEventSource): BaseUIElement { + public GetSimpleIcon(tags: Store): BaseUIElement { const self = this if (this.icon === undefined) { return undefined @@ -175,7 +175,7 @@ export default class PointRenderingConfig extends WithContextLoader { } public GenerateLeafletStyle( - tags: UIEventSource, + tags: Store, clickable: boolean, options?: { noSize?: false | boolean @@ -272,7 +272,7 @@ export default class PointRenderingConfig extends WithContextLoader { } } - private GetBadges(tags: UIEventSource): BaseUIElement { + private GetBadges(tags: Store): BaseUIElement { if (this.iconBadges.length === 0) { return undefined } @@ -304,7 +304,7 @@ export default class PointRenderingConfig extends WithContextLoader { ).SetClass("absolute bottom-0 right-1/3 h-1/2 w-0") } - private GetLabel(tags: UIEventSource): BaseUIElement { + private GetLabel(tags: Store): BaseUIElement { if (this.label === undefined) { return undefined } diff --git a/UI/BigComponents/SimpleAddUI.ts b/UI/BigComponents/SimpleAddUI.ts index 2cebb2512..adba53cba 100644 --- a/UI/BigComponents/SimpleAddUI.ts +++ b/UI/BigComponents/SimpleAddUI.ts @@ -1,7 +1,7 @@ /** * Asks to add a feature at the last clicked location, at least if zoom is sufficient */ -import { Store, UIEventSource } from "../../Logic/UIEventSource" +import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource" import Svg from "../../Svg" import { SubtleButton } from "../Base/SubtleButton" import Combine from "../Base/Combine" @@ -286,9 +286,16 @@ export default class SimpleAddUI extends LoginToggle { const presets = layer.layerDef.presets for (const preset of presets) { const tags = TagUtils.KVtoProperties(preset.tags ?? []) + const isSnapping = preset.preciseInput.snapToLayers?.length > 0 let icon: () => BaseUIElement = () => layer.layerDef.mapRendering[0] - .GenerateLeafletStyle(new UIEventSource(tags), false) + .GenerateLeafletStyle( + new ImmutableStore( + isSnapping ? tags : { _referencing_ways: ["way/-1"], ...tags } + ), + false, + { noSize: true } + ) .html.SetClass("w-12 h-12 block relative") const presetInfo: PresetInfo = { layerToAddTo: layer,