Fix selecting another background layer in minimaps
This commit is contained in:
parent
3f37848022
commit
6e9d4b327e
3 changed files with 15 additions and 4 deletions
|
@ -11,6 +11,10 @@ export class UIEventSource<T> {
|
||||||
constructor(data: T, tag: string = "") {
|
constructor(data: T, tag: string = "") {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
if(tag === undefined || tag === ""){
|
||||||
|
const callstack = new Error().stack.split("\n")
|
||||||
|
this.tag = callstack[1]
|
||||||
|
}
|
||||||
UIEventSource.allSources.push(this);
|
UIEventSource.allSources.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,9 +282,11 @@ export class UIEventSource<T> {
|
||||||
g: ((j: J, t: T) => T) = undefined): UIEventSource<J> {
|
g: ((j: J, t: T) => T) = undefined): UIEventSource<J> {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
const stack = new Error().stack.split("\n");
|
||||||
|
const callee = stack[1]
|
||||||
const newSource = new UIEventSource<J>(
|
const newSource = new UIEventSource<J>(
|
||||||
f(this.data),
|
f(this.data),
|
||||||
"map(" + this.tag + ")"
|
"map(" + this.tag + ")@"+callee
|
||||||
);
|
);
|
||||||
|
|
||||||
const update = function () {
|
const update = function () {
|
||||||
|
|
|
@ -197,6 +197,7 @@ export default class BackgroundMapSwitch extends Combine {
|
||||||
|
|
||||||
super(buttons)
|
super(buttons)
|
||||||
this.SetClass("flex")
|
this.SetClass("flex")
|
||||||
|
currentBackground.addCallbackAndRun(bg => console.trace("Current background is", bg.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ import Translations from "../i18n/Translations";
|
||||||
import Svg from "../../Svg";
|
import Svg from "../../Svg";
|
||||||
import Toggle from "../Input/Toggle";
|
import Toggle from "../Input/Toggle";
|
||||||
import SimpleAddUI, {PresetInfo} from "../BigComponents/SimpleAddUI";
|
import SimpleAddUI, {PresetInfo} from "../BigComponents/SimpleAddUI";
|
||||||
|
import BaseLayer from "../../Models/BaseLayer";
|
||||||
|
|
||||||
export default class ConfirmLocationOfPoint extends Combine {
|
export default class ConfirmLocationOfPoint extends Combine {
|
||||||
|
|
||||||
|
@ -19,7 +20,8 @@ export default class ConfirmLocationOfPoint extends Combine {
|
||||||
constructor(
|
constructor(
|
||||||
state: {
|
state: {
|
||||||
osmConnection: OsmConnection,
|
osmConnection: OsmConnection,
|
||||||
featurePipeline: FeaturePipeline
|
featurePipeline: FeaturePipeline,
|
||||||
|
backgroundLayer: UIEventSource<BaseLayer>
|
||||||
},
|
},
|
||||||
filterViewIsOpened: UIEventSource<boolean>,
|
filterViewIsOpened: UIEventSource<boolean>,
|
||||||
preset: PresetInfo,
|
preset: PresetInfo,
|
||||||
|
@ -35,9 +37,11 @@ export default class ConfirmLocationOfPoint extends Combine {
|
||||||
const zloc = {...loc, zoom: 19}
|
const zloc = {...loc, zoom: 19}
|
||||||
const locationSrc = new UIEventSource(zloc);
|
const locationSrc = new UIEventSource(zloc);
|
||||||
|
|
||||||
let backgroundLayer = undefined;
|
let backgroundLayer = new UIEventSource(state?.backgroundLayer?.data ?? AvailableBaseLayers.osmCarto);
|
||||||
if (preset.preciseInput.preferredBackground) {
|
if (preset.preciseInput.preferredBackground) {
|
||||||
backgroundLayer = AvailableBaseLayers.SelectBestLayerAccordingTo(locationSrc, new UIEventSource<string | string[]>(preset.preciseInput.preferredBackground))
|
const defaultBackground = AvailableBaseLayers.SelectBestLayerAccordingTo(locationSrc, new UIEventSource<string | string[]>(preset.preciseInput.preferredBackground));
|
||||||
|
// Note that we _break the link_ here, as the minimap will take care of the switching!
|
||||||
|
backgroundLayer.setData(defaultBackground.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
let snapToFeatures: UIEventSource<{ feature: any }[]> = undefined
|
let snapToFeatures: UIEventSource<{ feature: any }[]> = undefined
|
||||||
|
|
Loading…
Reference in a new issue