Skip to content

Commit

Permalink
Smoother location grant flow
Browse files Browse the repository at this point in the history
  • Loading branch information
42A7C5 committed Oct 28, 2024
1 parent 3fa43e4 commit 67cf7dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/setup_load_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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


Expand Down
4 changes: 3 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -857,6 +857,8 @@
mapglobal.flyTo(target);
}
} else {
start_location_watch();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/user_location_lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 67cf7dd

Please sign in to comment.