Coordis is a library to help you to deal with calculations involving geographical coordinates and conversion of units of measurement!
$ npm install coordis
OR
$ yarn add coordis
const coordis = require('coordis');
OR
import coordis from 'coordis';
const coordis = require('coordis');
const distanceInKm = coordis.toKilometers(
{
latitude: -23.6144942,
longitude: -46.7775026
},
{
latitude: -23.6144785,
longitude: -46.8453548
}
);
const distanceInMiles = coordis.toMiles(
{
latitude: -23.6144942,
longitude: -46.7775026
},
{
latitude: -23.6144785,
longitude: -46.8453548
}
);
console.log(distanceInKm, distanceInMiles);
Package Link: https://www.npmjs.com/package/coordis
Complete Docs: https://www.npmjs.com/package/coordis