Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@anatoliy-stepanchenko/geodistance-calculator

It is a simple npm package that allows you to calculate the approximate distance between two geographic coordinates (latitude and longitude) on Earth

geodistance, coordinates, distance calculation, geolocation, earth distance, geospatial, location utility, geography

readme

geodistance-calculator

A lightweight npm package for calculating the distance between two sets of geographic coordinates (latitude and longitude) on Earth.

Installation

To install this package, you can use npm or yarn:

npm install geodistance-calculator
# or
yarn install geodistance-calculator

Usage

Use the calculateDistance function to calculate the distance between two cities.

const calculateDistance = require("@anatoliy-stepanchenko/geodistance-calculator");

const londonCoords = { lat: 51.509865, lon: -0.118092 }; // London
const kyivCoords = { lat: 50.4501, lon: 30.5234 }; // Kyiv

const distance = calculateDistance(londonCoords, kyivCoords);

console.log(
  `The distance between London and Kyiv is approximately ${distance} kilometers.`
);

License

This package is open-source and available under the MIT License. See the LICENSE file for details.

Issues

If you encounter any issues or have questions, please create an issue in the GitHub repository.