TomTom Maps for JavaScript
    Preparing search index...

    Function formatDistance

    • Formatting is based on the number of meters passed and unit type. Less meters more precision.

      Parameters

      • meters: number
      • Optionaloptions: DistanceDisplayUnits

        Options for the display units, including their type and custom ways to display them.

      Returns string

      (null, METRIC) -> ""
      (0, METRIC) -> "0 m"
      (2, METRIC) -> "2 m"
      (237, METRIC) -> "240 m"
      (730, METRIC) -> "700 m"
      (950, METRIC) -> "1 km"
      (-999, METRIC) -> "-1 km"
      (2850, METRIC) -> "2.9 km"
      (283520, METRIC) -> "284 km"
      (2, IMPERIAL_US) -> "7 ft"
      (100, IMPERIAL_US) -> "330 ft"
      (182.88, IMPERIAL_US) -> "600 ft"
      (205.95, IMPERIAL_US) -> "¼ mi"
      (1205.95, IMPERIAL_US) -> "¾ mi"
      (5309.7, IMPERIAL_US) -> "3½ mi"
      (-18181.7, IMPERIAL_US) -> "-11 mi"
      (2, IMPERIAL_UK) -> "2 yd"
      (150.88, IMPERIAL_UK) -> "170 yd"
      (4344.3, IMPERIAL_UK) -> "2¾ mi"
      (21753.68, IMPERIAL_UK) -> "14 mi"