I'm working on a task where it is required to rotate the symbol on the line towards the latest marker based on the timestamp.
For example, when I select any marker it becomes pointA and the next point the line connected to is pointB.
if (pointA.timestamp > pointB.timestamp) {
// rotate towards PointA
} else {
// rotate towards PointB
}
I have searched for answers and tried turfjs bearing function but the angle that I'm getting is wrong I think this is the problem with Mapboxjs it shows the symbol perpendicular to the line.