Disable car loop animation for live tracking
This commit is contained in:
@@ -106,51 +106,17 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
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
|
||||
if (routePoints.length === 1) {
|
||||
// Canlı Takip Modu: Arabayı her zaman rotanın EN SON (en güncel) noktasına koy.
|
||||
var lastPoint = routePoints[routePoints.length - 1];
|
||||
var speedStr = vehicle.gps_speed ? vehicle.gps_speed + " km/s" : "0 km/s";
|
||||
var staticCar = L.marker(routePoints[0], {
|
||||
|
||||
var staticCar = L.marker(lastPoint, {
|
||||
icon: createLiveCarIcon(vehicle.driver_tag, speedStr)
|
||||
}).addTo(map);
|
||||
activeMarkers.push(staticCar);
|
||||
|
||||
// Haritayı doğrudan bu tek noktaya odakla (Zoom)
|
||||
map.setView(routePoints[0], 16);
|
||||
|
||||
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);
|
||||
activeMarkers.push(carMarker);
|
||||
|
||||
vehicleAnimationTimer = setInterval(function() {
|
||||
if (!routePoints || routePoints.length < 2) return;
|
||||
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);
|
||||
// Haritayı doğrudan bu son noktaya odakla (Zoom)
|
||||
map.setView(lastPoint, 16);
|
||||
}
|
||||
|
||||
function selectDriver(vehicle) {
|
||||
|
||||
Reference in New Issue
Block a user