Where to edit this Polyline

mbret8 months ago

Leaflet.js

deviceMotionEvent.addListener(function(deviceId) {
   API call: /api/positions?deviceId=deviceId
    var polyline = L.polyline([
        [latitude1, longitude1], // Position 1
        [latitude2, longitude2], // Position 2      
    ], {color: 'red'}).addTo(map);   
});
deviceStopEvent.addListener(function(deviceId) {  
    map.removeLayer(polyline);
});
mbret8 months ago

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);
Anton Tananaev8 months ago

How is this related to Traccar?