Fix undefined error in DirectionIndicator

This commit is contained in:
Pieter Vander Vennet 2023-12-26 12:35:51 +01:00
parent 8b6ee877f0
commit 0733c46fcb
2 changed files with 4 additions and 1 deletions

View file

@ -994,6 +994,9 @@ export class GeoOperations {
* @param meters
*/
public static distanceToHuman(meters: number): string {
if (meters === undefined) {
return ""
}
meters = Math.round(meters)
if (meters < 1000) {
return meters + "m"

View file

@ -109,7 +109,7 @@
<button class={twMerge("relative rounded-full soft", size)} use:ariaLabelStore={label} on:click={() => focusMap()}>
<div class={twMerge("absolute top-0 left-0 flex items-center justify-center text-sm break-words",size)}>
{GeoOperations.distanceToHuman($bearingAndDistGps.dist)}
{GeoOperations.distanceToHuman($bearingAndDistGps?.dist)}
</div>
{#if $bearingFromGps !== undefined}
<div class={twMerge("absolute top-0 left-0 rounded-full", size)}>