TIF_Nganjuk_E41212313/resources/views/kurir/track.blade.php

56 lines
1.9 KiB
PHP

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Tracking Lokasi Kurir</title>
</head>
<body style="font-family: sans-serif; padding: 2rem; text-align: center;">
<h2>📍 Tracking Lokasi Aktif</h2>
<p id="status">Menunggu update lokasi...</p>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
function uploadLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
const latitude = position.coords.latitude.toString();
const longitude = position.coords.longitude.toString();
axios.post('/location/store', {
latitude: latitude,
longitude: longitude,
_token: '{{ csrf_token() }}'
})
.then(function(response) {
console.log('Lokasi terkirim');
})
.catch(function(error) {
console.error('Gagal mengirim lokasi', error);
});
},
function(error) {
console.error('Gagal mengambil lokasi', error);
}
);
} else {
console.error('Browser tidak mendukung Geolocation.');
}
}
// Saat halaman selesai dimuat
window.onload = function () {
uploadLocation();
setInterval(uploadLocation, 10000); // Kirim ulang setiap 10 detik
};
// Paksa halaman reload setiap 60 detik
setInterval(function () {
window.location.reload();
}, 10000);
</script>
</body>
</html>