@bnidev/js-utils
    Preparing search index...

    Function haversineDistance

    • Calculates the Haversine distance between two geographical points.

      Parameters

      • lat1: number

        Latitude of the first point in degrees.

      • lon1: number

        Longitude of the first point in degrees.

      • lat2: number

        Latitude of the second point in degrees.

      • lon2: number

        Longitude of the second point in degrees.

      • unit: DistanceUnit = 'meters'

        The unit of measurement for the result ('meters', 'kilometers', or 'miles').

      Returns number

      The distance between the two points in the specified unit.

      // ES Module
      import { haversineDistance } from '@bnidev/js-utils'

      // CommonJS
      const { haversineDistance } = require('@bnidev/js-utils')
      const dist = haversineDistance(52.2296756, 21.0122287, 41.8919300, 12.5113300, 'kilometers')
      // dist will be approximately 1317.19 kilometers