diff --git a/src/locale/he.json b/src/locale/he.json index 81bb1730..f255390f 100644 --- a/src/locale/he.json +++ b/src/locale/he.json @@ -154,6 +154,16 @@ "at_time": "בשעה", "vehicle_ref": "לוחית רישוי", "drive_direction": "כיוון נסיעה", + "directions":{ + "North": "צפון", + "Northeast": "צפון-מזרח", + "East": "מזרח", + "Southeast": "דרום-מזרח", + "South": "דרום", + "Southwest": "דרום-מערב", + "West": "מערב", + "Northwest": "צפון-מערב" + }, "bearing": "מעלות", "coords": "נ.צ.", "hide_document": "הסתר מידע לגיקים", diff --git a/src/pages/components/map-related/MapLayers/BusToolTip.tsx b/src/pages/components/map-related/MapLayers/BusToolTip.tsx index a3a79487..98ce34a8 100644 --- a/src/pages/components/map-related/MapLayers/BusToolTip.tsx +++ b/src/pages/components/map-related/MapLayers/BusToolTip.tsx @@ -33,6 +33,26 @@ export function BusToolTip({ position, icon, children }: BusToolTipProps) { .finally(() => setIsLoading(false)) }, [position]) + function getDirectionFromAngle(angle: number): string { + // Normalize the angle to the range 0-360 + angle = ((angle % 360) + 360) % 360 + // Define the cardinal directions in clockwise order + const directions: string[] = [ + t('directions.North', { defaultValue: 'North' }), + t('directions.Northeast', { defaultValue: 'Northeast' }), + t('directions.East', { defaultValue: 'East' }), + t('directions.Southeast', { defaultValue: 'Southeast' }), + t('directions.South', { defaultValue: 'South' }), + t('directions.Southwest', { defaultValue: 'Southwest' }), + t('directions.West', { defaultValue: 'West' }), + t('directions.Northwest', { defaultValue: 'Northwest' }), + ] + // Divide the angle into 8 equal sections (45 degrees each) + const index: number = Math.round(angle / 45) % 8 + + return directions[index] + } + return (
{isLoading || !siriRide ? ( @@ -56,6 +76,7 @@ export function BusToolTip({ position, icon, children }: BusToolTipProps) {