List which pins are allowed by default
This commit is contained in:
parent
b583e930d3
commit
3b28e3ff21
3 changed files with 18 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
import {Utils} from "../Utils"
|
||||
import * as meta from "../package.json"
|
||||
|
||||
export type PriviligedLayerType = typeof Constants.priviliged_layers[number]
|
||||
|
||||
export default class Constants {
|
||||
|
@ -115,6 +116,11 @@ export default class Constants {
|
|||
static countryCoderEndpoint: string =
|
||||
"https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/latlon2country"
|
||||
public static readonly OsmPreferenceKeyPicturesLicense = "pictures-license"
|
||||
/**
|
||||
* These are the values that are allowed to use as 'backdrop' icon for a map pin
|
||||
*/
|
||||
private static readonly _defaultPinIcons = ["square", "circle", "none", "pin", "person", "plus", "ring", "star", "teardrop", "triangle", "crosshair",] as const
|
||||
public static readonly defaultPinIcons: string[] = <any>Constants._defaultPinIcons
|
||||
|
||||
private static isRetina(): boolean {
|
||||
if (Utils.runningFromConsole) {
|
||||
|
|
|
@ -11,6 +11,7 @@ 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";
|
||||
|
||||
export default class PointRenderingConfig extends WithContextLoader {
|
||||
static readonly allowed_location_codes: ReadonlySet<string> = new Set<string>([
|
||||
|
@ -86,7 +87,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
|||
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) {
|
||||
if (Constants.defaultPinIcons.indexOf(iconKey) < 0) {
|
||||
throw context + ": builtin SVG asset not found: " + iconPath
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ export default class PointRenderingConfig extends WithContextLoader {
|
|||
return undefined
|
||||
}
|
||||
const match = htmlSpec.match(/([a-zA-Z0-9_]*):([^;]*)/)
|
||||
if (match !== null && Svg.All[match[1] + ".svg"] !== undefined) {
|
||||
if (match !== null && Constants.defaultPinIcons.indexOf(match[1] ) >= 0) {
|
||||
const svg = Svg.All[match[1] + ".svg"] as string
|
||||
const targetColor = match[2]
|
||||
const img = new Img(
|
||||
|
|
|
@ -15,6 +15,7 @@ import {FixedUiElement} from "../../UI/Base/FixedUiElement"
|
|||
import {Paragraph} from "../../UI/Base/Paragraph"
|
||||
import Svg from "../../Svg"
|
||||
import Validators, {ValidatorType} from "../../UI/InputElement/Validators";
|
||||
import Constants from "../Constants";
|
||||
|
||||
export interface Mapping {
|
||||
readonly if: UploadableTag
|
||||
|
@ -374,9 +375,12 @@ export default class TagRenderingConfig {
|
|||
let iconClass = commonSize
|
||||
if (mapping.icon !== undefined) {
|
||||
if (typeof mapping.icon === "string" && mapping.icon !== "") {
|
||||
let stripped = mapping.icon
|
||||
if (stripped.endsWith(".svg")) {
|
||||
stripped = stripped.substring(0, stripped.length - 4)
|
||||
}
|
||||
if (
|
||||
Svg.All[mapping.icon] !== undefined ||
|
||||
Svg.All[mapping.icon + ".svg"] !== undefined
|
||||
Constants.defaultPinIcons.indexOf(stripped)
|
||||
) {
|
||||
icon = "./assets/svg/" + mapping.icon
|
||||
if (!icon.endsWith(".svg")) {
|
||||
|
|
Loading…
Reference in a new issue