feature: expose _referencing_ways/snap_to_layer in preset icon
This commit is contained in:
parent
6f4288476e
commit
08565dd20e
3 changed files with 15 additions and 8 deletions
|
@ -69,7 +69,7 @@ export class ReferencingWaysMetaTagger extends SimpleMetaTagger {
|
||||||
{
|
{
|
||||||
keys: ["_referencing_ways"],
|
keys: ["_referencing_ways"],
|
||||||
isLazy: true,
|
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) => {
|
(feature, _, __, state) => {
|
||||||
if (!ReferencingWaysMetaTagger.enabled) {
|
if (!ReferencingWaysMetaTagger.enabled) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { TagUtils } from "../../Logic/Tags/TagUtils"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
import Svg from "../../Svg"
|
import Svg from "../../Svg"
|
||||||
import WithContextLoader from "./WithContextLoader"
|
import WithContextLoader from "./WithContextLoader"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import BaseUIElement from "../../UI/BaseUIElement"
|
import BaseUIElement from "../../UI/BaseUIElement"
|
||||||
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
|
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
|
||||||
import Img from "../../UI/Base/Img"
|
import Img from "../../UI/Base/Img"
|
||||||
|
@ -164,7 +164,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
return PointRenderingConfig.FromHtmlMulti(htmlDefs, rotation, false, defaultPin)
|
return PointRenderingConfig.FromHtmlMulti(htmlDefs, rotation, false, defaultPin)
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetSimpleIcon(tags: UIEventSource<any>): BaseUIElement {
|
public GetSimpleIcon(tags: Store<any>): BaseUIElement {
|
||||||
const self = this
|
const self = this
|
||||||
if (this.icon === undefined) {
|
if (this.icon === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -175,7 +175,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenerateLeafletStyle(
|
public GenerateLeafletStyle(
|
||||||
tags: UIEventSource<any>,
|
tags: Store<any>,
|
||||||
clickable: boolean,
|
clickable: boolean,
|
||||||
options?: {
|
options?: {
|
||||||
noSize?: false | boolean
|
noSize?: false | boolean
|
||||||
|
@ -272,7 +272,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GetBadges(tags: UIEventSource<any>): BaseUIElement {
|
private GetBadges(tags: Store<any>): BaseUIElement {
|
||||||
if (this.iconBadges.length === 0) {
|
if (this.iconBadges.length === 0) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
).SetClass("absolute bottom-0 right-1/3 h-1/2 w-0")
|
).SetClass("absolute bottom-0 right-1/3 h-1/2 w-0")
|
||||||
}
|
}
|
||||||
|
|
||||||
private GetLabel(tags: UIEventSource<any>): BaseUIElement {
|
private GetLabel(tags: Store<any>): BaseUIElement {
|
||||||
if (this.label === undefined) {
|
if (this.label === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Asks to add a feature at the last clicked location, at least if zoom is sufficient
|
* 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 Svg from "../../Svg"
|
||||||
import { SubtleButton } from "../Base/SubtleButton"
|
import { SubtleButton } from "../Base/SubtleButton"
|
||||||
import Combine from "../Base/Combine"
|
import Combine from "../Base/Combine"
|
||||||
|
@ -286,9 +286,16 @@ export default class SimpleAddUI extends LoginToggle {
|
||||||
const presets = layer.layerDef.presets
|
const presets = layer.layerDef.presets
|
||||||
for (const preset of presets) {
|
for (const preset of presets) {
|
||||||
const tags = TagUtils.KVtoProperties(preset.tags ?? [])
|
const tags = TagUtils.KVtoProperties(preset.tags ?? [])
|
||||||
|
const isSnapping = preset.preciseInput.snapToLayers?.length > 0
|
||||||
let icon: () => BaseUIElement = () =>
|
let icon: () => BaseUIElement = () =>
|
||||||
layer.layerDef.mapRendering[0]
|
layer.layerDef.mapRendering[0]
|
||||||
.GenerateLeafletStyle(new UIEventSource<any>(tags), false)
|
.GenerateLeafletStyle(
|
||||||
|
new ImmutableStore<any>(
|
||||||
|
isSnapping ? tags : { _referencing_ways: ["way/-1"], ...tags }
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
{ noSize: true }
|
||||||
|
)
|
||||||
.html.SetClass("w-12 h-12 block relative")
|
.html.SetClass("w-12 h-12 block relative")
|
||||||
const presetInfo: PresetInfo = {
|
const presetInfo: PresetInfo = {
|
||||||
layerToAddTo: layer,
|
layerToAddTo: layer,
|
||||||
|
|
Loading…
Reference in a new issue