diff --git a/web-frontend/src/lib/Map.svelte b/web-frontend/src/lib/Map.svelte index 3ba2205..17da6a3 100644 --- a/web-frontend/src/lib/Map.svelte +++ b/web-frontend/src/lib/Map.svelte @@ -13,8 +13,10 @@ const locationCheckedChanged = () => { if (locationChecked) { + console.log('Starting location'); map.locate({ setView: true, watch: true, enableHighAccuracy: true }); } else { + console.log('Stopping location'); map.stopLocate(); } }; @@ -23,7 +25,14 @@ if (browser) { const leaflet = await import('leaflet'); - map = leaflet.map(mapElement).setView([51.505, -0.09], 13); + map = leaflet.map(mapElement); + // TODO: Pick a better spot + map.setView([51.505, -0.09], 13); + map.on('locationerror', (e) => { + console.error('Error getting location', e); + locationChecked = false; + locationCheckedChanged(); + }); map.on('click', onMapClick); map.on('locationfound', (e) => { dispatch('locationfound', e);