forked from MapComplete/MapComplete
Fix overlays in PDF, add overlay URL parameters
This commit is contained in:
parent
891c449058
commit
4e43673de5
9 changed files with 32 additions and 9 deletions
|
@ -508,7 +508,6 @@ export class InitUiElements {
|
||||||
|
|
||||||
|
|
||||||
const initialized =new Set()
|
const initialized =new Set()
|
||||||
|
|
||||||
for (const overlayToggle of State.state.overlayToggles) {
|
for (const overlayToggle of State.state.overlayToggles) {
|
||||||
new ShowOverlayLayer(overlayToggle.config, state.leafletMap, overlayToggle.isDisplayed)
|
new ShowOverlayLayer(overlayToggle.config, state.leafletMap, overlayToggle.isDisplayed)
|
||||||
initialized.add(overlayToggle.config)
|
initialized.add(overlayToggle.config)
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
*/
|
*/
|
||||||
export default interface TilesourceConfigJson {
|
export default interface TilesourceConfigJson {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Id of this overlay, used in the URL-parameters to set the state
|
||||||
|
*/
|
||||||
|
id: string,
|
||||||
/**
|
/**
|
||||||
* The path, where {x}, {y} and {z} will be substituted
|
* The path, where {x}, {y} and {z} will be substituted
|
||||||
*/
|
*/
|
||||||
source: string,
|
source: string,
|
||||||
|
/**
|
||||||
|
* Wether or not this is an overlay. Default: true
|
||||||
|
*/
|
||||||
isOverlay?: boolean,
|
isOverlay?: boolean,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -254,7 +254,7 @@ export default class LayerConfig {
|
||||||
)}`;
|
)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TagRenderingConfig("questions", undefined);
|
return new TagRenderingConfig("questions", undefined, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderingJson["override"] !== undefined) {
|
if (renderingJson["override"] !== undefined) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {Translation} from "../../UI/i18n/Translation";
|
||||||
|
|
||||||
export default class TilesourceConfig {
|
export default class TilesourceConfig {
|
||||||
public readonly source: string
|
public readonly source: string
|
||||||
|
public readonly id: string
|
||||||
public readonly isOverlay: boolean
|
public readonly isOverlay: boolean
|
||||||
public readonly name: Translation
|
public readonly name: Translation
|
||||||
public readonly minzoom: number
|
public readonly minzoom: number
|
||||||
|
@ -11,13 +12,16 @@ export default class TilesourceConfig {
|
||||||
public readonly defaultState: boolean;
|
public readonly defaultState: boolean;
|
||||||
|
|
||||||
constructor(config: TilesourceConfigJson, ctx: string = "") {
|
constructor(config: TilesourceConfigJson, ctx: string = "") {
|
||||||
|
this.id = config.id
|
||||||
this.source = config.source;
|
this.source = config.source;
|
||||||
this.isOverlay = config.isOverlay ?? false;
|
this.isOverlay = config.isOverlay ?? false;
|
||||||
this.name = Translations.T(config.name)
|
this.name = Translations.T(config.name)
|
||||||
this.minzoom = config.minZoom ?? 0
|
this.minzoom = config.minZoom ?? 0
|
||||||
this.maxzoom = config.maxZoom ?? 999
|
this.maxzoom = config.maxZoom ?? 999
|
||||||
this.defaultState = config.defaultState ?? true;
|
this.defaultState = config.defaultState ?? true;
|
||||||
|
if(this.id === undefined){
|
||||||
|
throw "An id is obligated"
|
||||||
|
}
|
||||||
if (this.minzoom > this.maxzoom) {
|
if (this.minzoom > this.maxzoom) {
|
||||||
throw "Invalid tilesourceConfig: minzoom should be smaller then maxzoom (at " + ctx + ")"
|
throw "Invalid tilesourceConfig: minzoom should be smaller then maxzoom (at " + ctx + ")"
|
||||||
}
|
}
|
||||||
|
|
2
State.ts
2
State.ts
|
@ -426,7 +426,7 @@ export default class State {
|
||||||
|
|
||||||
this.overlayToggles = this.layoutToUse.tileLayerSources.filter(c => c.name !== undefined).map(c => ({
|
this.overlayToggles = this.layoutToUse.tileLayerSources.filter(c => c.name !== undefined).map(c => ({
|
||||||
config: c,
|
config: c,
|
||||||
isDisplayed: new UIEventSource<boolean>(c.defaultState)
|
isDisplayed: QueryParameters.GetQueryParameter("overlay-"+c.id, ""+c.defaultState,"Wether or not the overlay "+c.id+" is shown").map(str => str === "true", [], b => ""+b)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||||
import FeaturePipeline from "../Logic/FeatureSource/FeaturePipeline";
|
import FeaturePipeline from "../Logic/FeatureSource/FeaturePipeline";
|
||||||
import ShowDataLayer from "./ShowDataLayer/ShowDataLayer";
|
import ShowDataLayer from "./ShowDataLayer/ShowDataLayer";
|
||||||
import {BBox} from "../Logic/BBox";
|
import {BBox} from "../Logic/BBox";
|
||||||
|
import ShowOverlayLayer from "./ShowDataLayer/ShowOverlayLayer";
|
||||||
/**
|
/**
|
||||||
* Creates screenshoter to take png screenshot
|
* Creates screenshoter to take png screenshot
|
||||||
* Creates jspdf and downloads it
|
* Creates jspdf and downloads it
|
||||||
|
@ -103,6 +104,19 @@ export default class ExportPDF {
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const initialized =new Set()
|
||||||
|
for (const overlayToggle of State.state.overlayToggles) {
|
||||||
|
new ShowOverlayLayer(overlayToggle.config, minimap.leafletMap, overlayToggle.isDisplayed)
|
||||||
|
initialized.add(overlayToggle.config)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const tileLayerSource of State.state.layoutToUse.tileLayerSources) {
|
||||||
|
if (initialized.has(tileLayerSource)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
new ShowOverlayLayer(tileLayerSource, minimap.leafletMap)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private cleanup() {
|
private cleanup() {
|
||||||
|
|
|
@ -133,7 +133,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
|
||||||
State.state.featureSwitchIsDebugging.map(isDebugging => {
|
State.state.featureSwitchIsDebugging.map(isDebugging => {
|
||||||
if (isDebugging) {
|
if (isDebugging) {
|
||||||
const config: TagRenderingConfig = new TagRenderingConfig({render: "{all_tags()}"}, new Tag("id", ""), "");
|
const config: TagRenderingConfig = new TagRenderingConfig({render: "{all_tags()}"}, new Tag("id", ""), "");
|
||||||
return new TagRenderingAnswer(tags, config)
|
return new TagRenderingAnswer(tags, config, "all_tags")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,13 +27,14 @@
|
||||||
},
|
},
|
||||||
"tileLayerSources": [
|
"tileLayerSources": [
|
||||||
{
|
{
|
||||||
|
"id": "property-boundaries",
|
||||||
"source": "https://tiles.osmuk.org/PropertyBoundaries/{z}/{x}/{y}.png",
|
"source": "https://tiles.osmuk.org/PropertyBoundaries/{z}/{x}/{y}.png",
|
||||||
"isOverlay": true,
|
"isOverlay": true,
|
||||||
"minZoom": 18,
|
"minZoom": 18,
|
||||||
"maxZoom": 20,
|
"maxZoom": 20,
|
||||||
"defaultState": false,
|
"defaultState": false,
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Parcel boundaries"
|
"en": "Property boundaries by osmuk.org"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -166,7 +166,7 @@ export default class TagSpec extends T {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
condition: "x="
|
condition: "x="
|
||||||
}, undefined, "");
|
}, undefined, "Tests");
|
||||||
|
|
||||||
equal(undefined, tr.GetRenderValue({"foo": "bar"}));
|
equal(undefined, tr.GetRenderValue({"foo": "bar"}));
|
||||||
equal("Has no name", tr.GetRenderValue({"noname": "yes"})?.txt);
|
equal("Has no name", tr.GetRenderValue({"noname": "yes"})?.txt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue