Файловый менеджер - Редактировать - /home/gqdcvggs/.trash/index.php.9
Назад
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Traçage de Route</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script> </head> <body class="bg-gray-900 text-white"> <div class="flex h-screen"> <div class="w-4/5"> <div id="map" class="h-full w-full"></div> </div> <div class="w-1/5 bg-gray-800 p-6 overflow-y-auto"> <h1 class="text-2xl font-elegant mb-6">Statistiques</h1> <div class="space-y-4"> <div class="bg-gray-700 p-4 rounded"> <p class="text-gray-300 text-sm">Heure</p> <p id="time" class="text-xl font-semibold">--:--:--</p> </div> <div class="bg-gray-700 p-4 rounded"> <p class="text-gray-300 text-sm">Pays</p> <p id="country" class="text-xl font-semibold">Chargement...</p> </div> <div class="bg-gray-700 p-4 rounded"> <p class="text-gray-300 text-sm">Connexion</p> <p id="connection" class="text-xl font-semibold">Vérification...</p> </div> <div class="bg-gray-700 p-4 rounded"> <p class="text-gray-300 text-sm">Vitesse</p> <p id="speed" class="text-xl font-semibold">0 km/h</p> </div> <div class="bg-gray-700 p-4 rounded"> <p class="text-gray-300 text-sm">Distance</p> <p id="distance" class="text-xl font-semibold">0 km</p> </div> <button id="startBtn" class="w-full bg-green-600 hover:bg-green-700 p-2 rounded mt-4">Démarrer</button> <button id="stopBtn" class="w-full bg-red-600 hover:bg-red-700 p-2 rounded disabled" disabled>Arrêter</button> </div> </div> </div> <style> @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&display=swap'); .font-elegant { font-family: 'Playfair Display', serif; } </style> <script> let map; let polyline; let route = []; let tracking = false; let lastPosition = null; let totalDistance = 0; let watchId = null; const updateTime = () => { const now = new Date(); document.getElementById('time').textContent = now.toLocaleTimeString('fr-FR'); }; const checkConnection = () => { const online = navigator.onLine; const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; const effectiveType = connection?.effectiveType || 'inconnue'; document.getElementById('connection').textContent = online ? `Stable (${effectiveType})` : 'Hors ligne'; }; const getCountry = (lat, lng) => { fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}`) .then(res => res.json()) .then(data => { const country = data.address?.country || 'Inconnu'; document.getElementById('country').textContent = country; }) .catch(() => { document.getElementById('country').textContent = 'Erreur'; }); }; const calculateDistance = (lat1, lng1, lat2, lng2) => { const R = 6371; const dLat = (lat2 - lat1) * Math.PI / 180; const dLng = (lng2 - lng1) * Math.PI / 180; const a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLng/2) * Math.sin(dLng/2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); return R * c; }; const updateSpeed = (lat, lng, timestamp) => { if (!lastPosition) { lastPosition = { lat, lng, timestamp }; return; } const distance = calculateDistance(lastPosition.lat, lastPosition.lng, lat, lng) * 1000; const timeDiff = (timestamp - lastPosition.timestamp) / 1000; const speed = (distance / timeDiff) * 3.6; document.getElementById('speed').textContent = speed.toFixed(2) + ' km/h'; lastPosition = { lat, lng, timestamp }; }; const startTracking = () => { tracking = true; route = []; totalDistance = 0; document.getElementById('startBtn').disabled = true; document.getElementById('stopBtn').disabled = false; if (navigator.geolocation) { watchId = navigator.geolocation.watchPosition( (position) => { const lat = position.coords.latitude; const lng = position.coords.longitude; const timestamp = position.timestamp; route.push([lat, lng]); updateSpeed(lat, lng, timestamp); getCountry(lat, lng); if (route.length > 1) { totalDistance += calculateDistance(route[route.length - 2][0], route[route.length - 2][1], lat, lng); document.getElementById('distance').textContent = totalDistance.toFixed(2) + ' km'; } if (polyline) { map.removeLayer(polyline); } polyline = L.polyline(route, { color: 'red', weight: 3 }).addTo(map); map.setView([lat, lng], 15); localStorage.setItem('route', JSON.stringify(route)); }, (error) => { console.error('Erreur géolocalisation:', error); }, { enableHighAccuracy: true, maximumAge: 0, timeout: 5000 } ); } }; const stopTracking = () => { tracking = false; if (watchId) { navigator.geolocation.clearWatch(watchId); } document.getElementById('startBtn').disabled = false; document.getElementById('stopBtn').disabled = true; }; window.addEventListener('online', checkConnection); window.addEventListener('offline', checkConnection); map = L.map('map').setView([48.8566, 2.3522], 13); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap', maxZoom: 19 }).addTo(map); document.getElementById('startBtn').addEventListener('click', startTracking); document.getElementById('stopBtn').addEventListener('click', stopTracking); setInterval(updateTime, 1000); setInterval(checkConnection, 5000); updateTime(); checkConnection(); const savedRoute = localStorage.getItem('route'); if (savedRoute) { route = JSON.parse(savedRoute); if (route.length > 0) { polyline = L.polyline(route, { color: 'blue', weight: 2 }).addTo(map); map.fitBounds(polyline.getBounds()); } } </script> </body> </html>
| ver. 1.6 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка