function sledujPolohu(callback) { if (!navigator.geolocation) { console.log("Geolocation nie je podporovaná."); return; } navigator.geolocation.watchPosition( position => { const lat = position.coords.latitude; const lon = position.coords.longitude; const accuracy = position.coords.accuracy; callback({ lat: lat, lon: lon, accuracy: accuracy }); }, error => { console.error( "GPS chyba:", error.message ); }, { enableHighAccuracy: true, maximumAge: 2000, timeout: 10000 } ); } sledujPolohu(poloha => { console.log("LAT:", poloha.lat); console.log("LON:", poloha.lon); console.log("Presnosť:", poloha.accuracy, "m"); }); sledujPolohu(poloha => { aktualnaPoloha = poloha; vykresliMapu(); });