Disable car loop animation for live tracking

This commit is contained in:
cerenX9
2026-07-24 14:33:30 +03:00
parent 7b6660952c
commit 4ed6b5b725

View File

@@ -106,51 +106,17 @@ document.addEventListener("DOMContentLoaded", function() {
} }
if (!routePoints || routePoints.length === 0) return; if (!routePoints || routePoints.length === 0) return;
// Eğer sadece tek bir nokta varsa (Canlı Anlık GPS modu), arabayı sabit bir şekilde o noktaya koy // Canlı Takip Modu: Arabayı her zaman rotanın EN SON (en güncel) noktasına koy.
if (routePoints.length === 1) { var lastPoint = routePoints[routePoints.length - 1];
var speedStr = vehicle.gps_speed ? vehicle.gps_speed + " km/s" : "0 km/s"; var speedStr = vehicle.gps_speed ? vehicle.gps_speed + " km/s" : "0 km/s";
var staticCar = L.marker(routePoints[0], {
icon: createLiveCarIcon(vehicle.driver_tag, speedStr)
}).addTo(map);
activeMarkers.push(staticCar);
// Haritayı doğrudan bu tek noktaya odakla (Zoom) var staticCar = L.marker(lastPoint, {
map.setView(routePoints[0], 16); icon: createLiveCarIcon(vehicle.driver_tag, speedStr)
return;
}
var currentIdx = 0;
var progress = 0;
var stepSize = 0.08; // Akıcı hareket adımı
var carMarker = L.marker(routePoints[0], {
icon: createLiveCarIcon(vehicle.driver_tag, "52 km/s")
}).addTo(map); }).addTo(map);
activeMarkers.push(carMarker); activeMarkers.push(staticCar);
vehicleAnimationTimer = setInterval(function() { // Haritayı doğrudan bu son noktaya odakla (Zoom)
if (!routePoints || routePoints.length < 2) return; map.setView(lastPoint, 16);
progress += stepSize;
if (progress >= 1) {
progress = 0;
currentIdx++;
if (currentIdx >= routePoints.length - 1) {
currentIdx = 0; // Rotayı sürekli akıcı döngüde yenile
}
}
var p1 = routePoints[currentIdx];
var p2 = routePoints[currentIdx + 1];
var lat = p1[0] + (p2[0] - p1[0]) * progress;
var lng = p1[1] + (p2[1] - p1[1]) * progress;
// Anlık simüle edilen canlı hız (48 - 65 km/s arası dinamik değişim)
var currentSpeed = Math.floor(48 + Math.abs(Math.sin(currentIdx + progress)) * 17) + " km/s";
carMarker.setLatLng([lat, lng]);
carMarker.setIcon(createLiveCarIcon(vehicle.driver_tag, currentSpeed));
}, 120);
} }
function selectDriver(vehicle) { function selectDriver(vehicle) {