fix: can't determine location

This commit is contained in:
log101 2024-02-01 21:44:50 +03:00
parent 0d7524edec
commit d7809d80ab
3 changed files with 7 additions and 3 deletions

View File

@ -58,7 +58,7 @@ const LocationButton = ({
} }
}, },
() => null, () => null,
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 } { enableHighAccuracy: true, timeout: 27000, maximumAge: 10000 }
) )
setWatchId(id) setWatchId(id)

View File

@ -6,6 +6,7 @@ let watchId = -1;
function startWatchingLocation() { function startWatchingLocation() {
watchId = navigator.geolocation.watchPosition( watchId = navigator.geolocation.watchPosition(
(position) => { (position) => {
console.log('watching')
const pos = { const pos = {
lat: position.coords.latitude, lat: position.coords.latitude,
lng: position.coords.longitude lng: position.coords.longitude
@ -19,8 +20,10 @@ function startWatchingLocation() {
} }
}, },
() => null, () => null,
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 } { enableHighAccuracy: true, timeout: 27000, maximumAge: 10000 }
) )
console.log('trying', watchId)
} }
var map = L.map('map').setView(TARGET_LOCATION, 13); var map = L.map('map').setView(TARGET_LOCATION, 13);
@ -73,6 +76,7 @@ L.Control.GoToCurrentLocation = L.Control.extend({
startWatchingLocation() startWatchingLocation()
locationButton.textContent = 'Konumuma Git'; locationButton.textContent = 'Konumuma Git';
} else { } else {
console.log(currentLocationMarker)
map.setView(currentLocationMarker.getLatLng(), 12); map.setView(currentLocationMarker.getLatLng(), 12);
} }
}); });

View File

@ -39,7 +39,7 @@ function startWatchingLocation() {
} }
}, },
() => null, () => null,
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 } { enableHighAccuracy: true, timeout: 27000, maximumAge: 10000 }
) )
} }