forked from MapComplete/MapComplete
Allow to style special visualisations, no cursor if popups are disabled
This commit is contained in:
parent
c13e6727c3
commit
5e991bdc02
7 changed files with 19 additions and 15 deletions
|
@ -183,7 +183,7 @@ export default class LayerConfig {
|
||||||
|
|
||||||
const keys = Array.from(SharedTagRenderings.SharedTagRendering.keys())
|
const keys = Array.from(SharedTagRenderings.SharedTagRendering.keys())
|
||||||
|
|
||||||
throw `Predefined tagRendering ${renderingJson} not found in ${context}.\n Try one of ${(keys.join(", "))}`;
|
throw `Predefined tagRendering ${renderingJson} not found in ${context}.\n Try one of ${(keys.join(", "))}\n If you intent to output this text literally, use {\"render\": <your text>} instead"}`;
|
||||||
}
|
}
|
||||||
return new TagRenderingConfig(renderingJson, self.source.osmTags, `${context}.tagrendering[${i}]`);
|
return new TagRenderingConfig(renderingJson, self.source.osmTags, `${context}.tagrendering[${i}]`);
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,9 +101,13 @@ export default class ShowDataLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = layer.GenerateLeafletStyle(tagSource, !(layer.title === undefined && (layer.tagRenderings ?? []).length === 0));
|
const style = layer.GenerateLeafletStyle(tagSource, !(layer.title === undefined && (layer.tagRenderings ?? []).length === 0));
|
||||||
|
const baseElement = style.icon.html;
|
||||||
|
if(!this._enablePopups){
|
||||||
|
baseElement.SetStyle("cursor: initial !important")
|
||||||
|
}
|
||||||
return L.marker(latLng, {
|
return L.marker(latLng, {
|
||||||
icon: L.divIcon({
|
icon: L.divIcon({
|
||||||
html: style.icon.html.ConstructElement(),
|
html: baseElement.ConstructElement(),
|
||||||
className: style.icon.className,
|
className: style.icon.className,
|
||||||
iconAnchor: style.icon.iconAnchor,
|
iconAnchor: style.icon.iconAnchor,
|
||||||
iconUrl: style.icon.iconUrl,
|
iconUrl: style.icon.iconUrl,
|
||||||
|
@ -119,12 +123,9 @@ export default class ShowDataLayer {
|
||||||
console.warn("No layer found for object (probably a now disabled layer)", feature, this._layerDict)
|
console.warn("No layer found for object (probably a now disabled layer)", feature, this._layerDict)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (layer.title === undefined) {
|
if (layer.title === undefined || !this._enablePopups) {
|
||||||
// No popup action defined -> Don't do anything
|
// No popup action defined -> Don't do anything
|
||||||
return;
|
// or probably a map in the popup - no popups needed!
|
||||||
}
|
|
||||||
if(!this._enablePopups){
|
|
||||||
// Probably a map in the popup - no popups needed!
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ export default class SpecialVisualizations {
|
||||||
return new Combine([
|
return new Combine([
|
||||||
new Title("Special tag renderings", 3),
|
new Title("Special tag renderings", 3),
|
||||||
"In a tagrendering, some special values are substituted by an advanced UI-element. This allows advanced features and visualizations to be reused by custom themes or even to query third-party API's.",
|
"In a tagrendering, some special values are substituted by an advanced UI-element. This allows advanced features and visualizations to be reused by custom themes or even to query third-party API's.",
|
||||||
"General usage is <b>{func_name()}</b> or <b>{func_name(arg, someotherarg)}</b>. Note that you <i>do not</i> need to use quotes around your arguments, the comma is enough to seperate them. This also implies you cannot use a comma in your args",
|
"General usage is <b>{func_name()}</b>, <b>{func_name(arg, someotherarg)}</b> or <b>{func_name(args):cssStyle}</b>. Note that you <i>do not</i> need to use quotes around your arguments, the comma is enough to seperate them. This also implies you cannot use a comma in your args",
|
||||||
...helpTexts
|
...helpTexts
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class SubstitutedTranslation extends VariableUiElement {
|
||||||
// We found a special component that should be brought to live
|
// We found a special component that should be brought to live
|
||||||
const partBefore = SubstitutedTranslation.EvaluateSpecialComponents(matched[1], tags);
|
const partBefore = SubstitutedTranslation.EvaluateSpecialComponents(matched[1], tags);
|
||||||
const argument = matched[2].trim();
|
const argument = matched[2].trim();
|
||||||
const style = matched[3] ?? ""
|
const style = matched[3]?.substring(1) ?? ""
|
||||||
const partAfter = SubstitutedTranslation.EvaluateSpecialComponents(matched[4], tags);
|
const partAfter = SubstitutedTranslation.EvaluateSpecialComponents(matched[4], tags);
|
||||||
try {
|
try {
|
||||||
const args = knownSpecial.args.map(arg => arg.defaultValue ?? "");
|
const args = knownSpecial.args.map(arg => arg.defaultValue ?? "");
|
||||||
|
|
|
@ -72,7 +72,9 @@
|
||||||
],
|
],
|
||||||
"tagRenderings": [
|
"tagRenderings": [
|
||||||
"images",
|
"images",
|
||||||
"minimap",
|
{
|
||||||
|
"render": "{minimap():height: 9rem; border-radius: 2.5rem; overflow:hidden;border:1px solid gray}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"render": {
|
"render": {
|
||||||
"en": "The name of this bookcase is {name}",
|
"en": "The name of this bookcase is {name}",
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import {lstatSync, readdirSync, readFileSync} from "fs";
|
import {lstatSync, readdirSync, readFileSync} from "fs";
|
||||||
|
import {Utils} from "../Utils";
|
||||||
|
Utils.runningFromConsole = true
|
||||||
import * as https from "https";
|
import * as https from "https";
|
||||||
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
||||||
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {Utils} from "../Utils";
|
|
||||||
|
|
||||||
export default class ScriptUtils {
|
export default class ScriptUtils {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import ScriptUtils from "./ScriptUtils";
|
import ScriptUtils from "./ScriptUtils";
|
||||||
import {Utils} from "../Utils";
|
import {writeFileSync} from "fs";
|
||||||
import {readFileSync, writeFileSync} from "fs";
|
|
||||||
|
|
||||||
Utils.runningFromConsole = true
|
|
||||||
import LayerConfig from "../Customizations/JSON/LayerConfig";
|
import LayerConfig from "../Customizations/JSON/LayerConfig";
|
||||||
import * as licenses from "../assets/generated/license_info.json"
|
import * as licenses from "../assets/generated/license_info.json"
|
||||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||||
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
||||||
import {Translation} from "../UI/i18n/Translation";
|
import {Translation} from "../UI/i18n/Translation";
|
||||||
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
import {LayoutConfigJson} from "../Customizations/JSON/LayoutConfigJson";
|
||||||
|
|
||||||
|
|
||||||
// This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files.
|
// This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files.
|
||||||
// It spits out an overview of those to be used to load them
|
// It spits out an overview of those to be used to load them
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue