I'm using Leaflet + Leaflet's rotate-branch to rotate my map application.
map.setBearing(angle_deg);
is the function to do so. angle_deg
has to be between 0 and 359 to simulate any desired angle. I want the map to follow and rotate in relation to the users current position and walking direction.
In order to avoid math, I wanted to use Leaflet.GeometryUtil to do the calculations for me, but only was able to find the functions bearing()
and computeAngle()
, which yield the same result: horizontal heading between two coordinates (0 up to 180 clockwise and back to 0 again in axial symmetry with a minus sign).
How can I transform this into a full 360 degree value?
To further illustrate:
0 360/0
-90 90 to 270 90
+/-180 180
Could I just add 360 to all negative values and be fine?