Handle location errors more gracefully
This commit is contained in:
parent
acc29a704f
commit
8259d37022
@ -13,8 +13,10 @@
|
|||||||
|
|
||||||
const locationCheckedChanged = () => {
|
const locationCheckedChanged = () => {
|
||||||
if (locationChecked) {
|
if (locationChecked) {
|
||||||
|
console.log('Starting location');
|
||||||
map.locate({ setView: true, watch: true, enableHighAccuracy: true });
|
map.locate({ setView: true, watch: true, enableHighAccuracy: true });
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Stopping location');
|
||||||
map.stopLocate();
|
map.stopLocate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -23,7 +25,14 @@
|
|||||||
if (browser) {
|
if (browser) {
|
||||||
const leaflet = await import('leaflet');
|
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('click', onMapClick);
|
||||||
map.on('locationfound', (e) => {
|
map.on('locationfound', (e) => {
|
||||||
dispatch('locationfound', e);
|
dispatch('locationfound', e);
|
||||||
|
Loading…
Reference in New Issue
Block a user