diff --git a/src/components/setup_load_map.ts b/src/components/setup_load_map.ts index 7475133..8400f99 100644 --- a/src/components/setup_load_map.ts +++ b/src/components/setup_load_map.ts @@ -21,7 +21,7 @@ import { makeCircleLayers } from './addLayers/addLiveDots'; import { makeBearingArrowPointers } from './addLayers/makebearingarrowpointers'; import { makeGpsLayer } from './makeGpsLayer'; import { makeContextLayerDataset } from './addLayers/contextLayer'; -import { start_location_watch } from '../user_location_lib'; +import { has_permission_to_geolocate, start_location_watch } from '../user_location_lib'; export function setup_load_map( map: mapboxgl.Map, @@ -37,7 +37,10 @@ export function setup_load_map( map.on('load', () => { recompute_map_padding(); clearbottomright(); - start_location_watch(); + + if (has_permission_to_geolocate()) { + start_location_watch(); + } // Add new sources and layers diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 48ea0e6..e81bf2c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -11,7 +11,7 @@ import { _ } from 'svelte-i18n'; import { isLoading } from 'svelte-i18n'; import { changeRailTextOutsideNorthAmerica } from '../components/addLayers/addStops'; - import { update_geolocation_source } from '../user_location_lib'; + import { start_location_watch, update_geolocation_source } from '../user_location_lib'; import { dark_mode_store, @@ -857,6 +857,8 @@ mapglobal.flyTo(target); } + } else { + start_location_watch(); } } diff --git a/src/user_location_lib.ts b/src/user_location_lib.ts index 97d3b26..bc8ee78 100644 --- a/src/user_location_lib.ts +++ b/src/user_location_lib.ts @@ -13,8 +13,8 @@ geolocation_store.subscribe((g) => { export function start_location_watch() { function success(pos: GeolocationPosition ) { + window.localStorage.setItem(permission_to_geolocate, 'true'); geolocation_store.set(pos); - update_geolocation_source(); }