From a723001dbbc3643f0e74317de18dd01407ba82e3 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 25 Mar 2023 23:27:18 -0400 Subject: [PATCH] Stop location when switching tabs --- web-frontend/src/lib/Map.svelte | 12 +++++++++++- web-frontend/src/routes/app/+page.svelte | 10 +++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/web-frontend/src/lib/Map.svelte b/web-frontend/src/lib/Map.svelte index fd21838..6f62600 100644 --- a/web-frontend/src/lib/Map.svelte +++ b/web-frontend/src/lib/Map.svelte @@ -9,15 +9,25 @@ let locationChecked; let locationControl; + export let isVisible = true; export let onMapClick = () => {}; export let map; + $: if (isVisible) { + locationCheckedChanged(false); + } + const locationCheckedChanged = (setValue) => { + if (!map) { + return; + } if (setValue === true || setValue === false) { // Shortcut to set it in this function, if they passed a boolean locationChecked = !!setValue; } + console.log('Setting chceked to ', setValue); + if (locationChecked) { map.locate({ setView: true, watch: true, enableHighAccuracy: true }); } else { @@ -103,7 +113,7 @@ }); -
+
diff --git a/web-frontend/src/routes/app/+page.svelte b/web-frontend/src/routes/app/+page.svelte index a1bd1d7..80d2808 100644 --- a/web-frontend/src/routes/app/+page.svelte +++ b/web-frontend/src/routes/app/+page.svelte @@ -156,6 +156,12 @@ outputValue = `${e}`; } }; + + let mapIsVisible = false; + + $: { + mapIsVisible = initSuccess && tabInfo.selected == 0; + }

App

@@ -193,6 +199,4 @@ Could not start core module {/await} - - - +