From d04f56603eb3f18e9a8e2a1991d49559a14b3a24 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 7 Feb 2023 02:11:17 +0100 Subject: [PATCH] Fix #1304 --- UI/BigComponents/GeolocationControl.ts | 4 ++-- UI/BigComponents/RightControls.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/UI/BigComponents/GeolocationControl.ts b/UI/BigComponents/GeolocationControl.ts index d0e286b51a..dfb50fe21b 100644 --- a/UI/BigComponents/GeolocationControl.ts +++ b/UI/BigComponents/GeolocationControl.ts @@ -27,9 +27,9 @@ export class GeolocationControl extends VariableUiElement { const timeDiff = (new Date().getTime() - lastClick.getTime()) / 1000 return timeDiff <= 3 }) - const geolocationState = geolocationHandler.geolocationState + const geolocationState = geolocationHandler?.geolocationState super( - geolocationState.permission.map( + geolocationState?.permission?.map( (permission) => { if (permission === "denied") { return Svg.location_refused_svg() diff --git a/UI/BigComponents/RightControls.ts b/UI/BigComponents/RightControls.ts index 2ce468065b..189559ba54 100644 --- a/UI/BigComponents/RightControls.ts +++ b/UI/BigComponents/RightControls.ts @@ -13,12 +13,10 @@ export default class RightControls extends Combine { state: MapState & { featurePipeline: FeaturePipeline }, geolocationHandler: GeoLocationHandler ) { - const geolocationButton = new Toggle( + const geolocationButton = Toggle.If(state.featureSwitchGeolocation, () => new MapControlButton(new GeolocationControl(geolocationHandler, state), { dontStyle: true, - }).SetClass("p-1"), - undefined, - state.featureSwitchGeolocation + }).SetClass("p-1") ) const plus = new MapControlButton(Svg.plus_svg()).onClick(() => {