Fix: fix icons in mappings which use a builtin svg

This commit is contained in:
Pieter Vander Vennet 2023-05-09 00:05:38 +02:00
parent beb86919a8
commit ab28fbe35c
2 changed files with 33 additions and 31 deletions

View file

@ -1,17 +1,16 @@
import PointRenderingConfigJson from "./Json/PointRenderingConfigJson"
import TagRenderingConfig from "./TagRenderingConfig"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import { TagUtils } from "../../Logic/Tags/TagUtils"
import { Utils } from "../../Utils"
import {TagsFilter} from "../../Logic/Tags/TagsFilter"
import {TagUtils} from "../../Logic/Tags/TagUtils"
import {Utils} from "../../Utils"
import Svg from "../../Svg"
import WithContextLoader from "./WithContextLoader"
import { Store } from "../../Logic/UIEventSource"
import {Store} from "../../Logic/UIEventSource"
import BaseUIElement from "../../UI/BaseUIElement"
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import {FixedUiElement} from "../../UI/Base/FixedUiElement"
import Img from "../../UI/Base/Img"
import Combine from "../../UI/Base/Combine"
import { VariableUiElement } from "../../UI/Base/VariableUIElement"
import Constants from "../Constants";
import {VariableUiElement} from "../../UI/Base/VariableUIElement"
export default class PointRenderingConfig extends WithContextLoader {
static readonly allowed_location_codes: ReadonlySet<string> = new Set<string>([
@ -84,7 +83,7 @@ export default class PointRenderingConfig extends WithContextLoader {
}
})
const iconPath = this.icon?.GetRenderValue({ id: "node/-1" })?.txt
const iconPath = this.icon?.GetRenderValue({id: "node/-1"})?.txt
if (iconPath !== undefined && iconPath.startsWith(Utils.assets_path)) {
const iconKey = iconPath.substr(Utils.assets_path.length)
if (Svg.All[iconKey] === undefined) {
@ -110,7 +109,7 @@ export default class PointRenderingConfig extends WithContextLoader {
return undefined
}
const match = htmlSpec.match(/([a-zA-Z0-9_]*):([^;]*)/)
if (match !== null && Constants.defaultPinIcons.indexOf(match[1] ) >= 0) {
if (match !== null && Svg.All[match[1] + ".svg"] !== undefined) {
const svg = Svg.All[match[1] + ".svg"] as string
const targetColor = match[2]
const img = new Img(
@ -169,7 +168,7 @@ export default class PointRenderingConfig extends WithContextLoader {
noFullWidth?: boolean
}
): BaseUIElement {
tags = tags ?? { id: "node/-1" }
tags = tags ?? {id: "node/-1"}
let defaultPin: BaseUIElement = undefined
if (this.label === undefined) {
defaultPin = Svg.teardrop_with_hole_green_svg()