We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d64bc9 commit 2a3a34aCopy full SHA for 2a3a34a
src/lib/MapHelpers/generateVehicleIcon.js
@@ -12,8 +12,14 @@ const DIRECTIONS = [
12
];
13
14
function getDirectionFromOrientation(orientation) {
15
- const nearestDirection = DIRECTIONS.reduce((prev, curr) =>
16
- Math.abs(curr.angle - orientation) < Math.abs(prev.angle - orientation) ? curr : prev
+ if (DIRECTIONS.length === 0) {
+ return null;
17
+ }
18
+
19
+ const nearestDirection = DIRECTIONS.reduce(
20
+ (prev, curr) =>
21
+ Math.abs(curr.angle - orientation) < Math.abs(prev.angle - orientation) ? curr : prev,
22
+ DIRECTIONS[0]
23
);
24
return nearestDirection.icon;
25
}
0 commit comments