other option
var polylineCoordinates = [];
API call: /api/positions?deviceId=deviceId
setInterval(function() {
positionData.forEach(function(position) {
var lat = position.latitude;
var lon = position.longitude;
polylineCoordinates.push([lat, lon]);
});
if (polylineCoordinates.length > 1) {
if (polyline) {
map.removeLayer(polyline);
}
polyline = L.polyline(polylineCoordinates, {color: 'blue'}).addTo(map);
map.fitBounds(polyline.getBounds());
}
}, 5000);
How is this related to Traccar?
Leaflet.js