diff --git a/UI/BigComponents/BackgroundMapSwitch.ts b/UI/BigComponents/BackgroundMapSwitch.ts index fa601b3d39..68e3e77d95 100644 --- a/UI/BigComponents/BackgroundMapSwitch.ts +++ b/UI/BigComponents/BackgroundMapSwitch.ts @@ -165,9 +165,13 @@ export default class BackgroundMapSwitch extends Combine { backgroundLayer: UIEventSource }, currentBackground: UIEventSource, - preferredCategory?: string + options?:{ + preferredCategory?: string, + allowedCategories?: ("osmbasedmap" | "photo" | "map")[] + + } ) { - const allowedCategories = ["osmbasedmap", "photo", "map"] + const allowedCategories = options?.allowedCategories ?? ["osmbasedmap", "photo", "map"] const previousLayer = state.backgroundLayer.data const buttons = [] @@ -188,7 +192,7 @@ export default class BackgroundMapSwitch extends Combine { }) // Fall back to the first option: OSM activatePrevious = activatePrevious ?? button.activate - if (category === preferredCategory) { + if (category === options?.preferredCategory) { button.activate() } buttons.push(button) diff --git a/UI/Input/LengthInput.ts b/UI/Input/LengthInput.ts index 486d6c4c39..a6941082b3 100644 --- a/UI/Input/LengthInput.ts +++ b/UI/Input/LengthInput.ts @@ -5,8 +5,9 @@ import Svg from "../../Svg"; import {Utils} from "../../Utils"; import Loc from "../../Models/Loc"; import {GeoOperations} from "../../Logic/GeoOperations"; -import Minimap from "../Base/Minimap"; +import Minimap, {MinimapObj} from "../Base/Minimap"; import BackgroundMapSwitch from "../BigComponents/BackgroundMapSwitch"; +import BaseUIElement from "../BaseUIElement"; /** @@ -39,8 +40,8 @@ export default class LengthInput extends InputElement { } protected InnerConstructElement(): HTMLElement { - // @ts-ignore - let map = undefined + let map : (BaseUIElement & MinimapObj) = undefined + let layerControl : BaseUIElement = undefined if (!Utils.runningFromConsole) { map = Minimap.createMiniMap({ background: this.background, @@ -51,6 +52,14 @@ export default class LengthInput extends InputElement { tap: true } }) + + layerControl = new BackgroundMapSwitch({ + locationControl: this._location, + backgroundLayer: this.background, + }, this.background,{ + allowedCategories: ["map","photo"] + }) + } const element = new Combine([ new Combine([Svg.length_crosshair_svg().SetStyle( @@ -58,6 +67,7 @@ export default class LengthInput extends InputElement { ]) .SetClass("block length-crosshair-svg relative") .SetStyle("z-index: 1000; visibility: hidden"), + layerControl?.SetStyle("position: absolute; bottom: 0.25rem; left: 0.25rem; z-index: 1000"), map?.SetClass("w-full h-full block absolute top-0 left-O overflow-hidden"), ]) .SetClass("relative block bg-white border border-black rounded-3xl overflow-hidden")