https://github.com/joelcolucci/geolocation-distance-between
ES6 module to calculate distance between coordinates
https://github.com/joelcolucci/geolocation-distance-between
coordinates distance geolocation haversine latitude longitude
Last synced: about 1 year ago
JSON representation
ES6 module to calculate distance between coordinates
- Host: GitHub
- URL: https://github.com/joelcolucci/geolocation-distance-between
- Owner: joelcolucci
- License: mit
- Created: 2018-08-15T22:41:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T12:03:00.000Z (over 7 years ago)
- Last Synced: 2025-02-14T10:15:37.184Z (about 1 year ago)
- Topics: coordinates, distance, geolocation, haversine, latitude, longitude
- Language: JavaScript
- Size: 39.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# geolocation-distance-between [](https://www.npmjs.com/package/geolocation-distance-between)
> ES6 module to calculate distance between coordinates
## Installation
```
# NPM
npm install geolocation-distance-between --save
# Yarn
yarn add geolocation-distance-between
```
## Getting Started
```javascript
import { getDistanceBetween } from 'geolocation-distance-between';
let coordinateOne = {latitude: 41.3543, longitude: 71.9665};
let coordianteTwo = {latitude: 41.3890, longitude: 70.5134};
let distanceBetween = getDistanceBetween(coordinateOne, coordinateTwo);
console.log(distanceBetween); // 121.31393500601737 KM
```
## Documentation
### `getDistanceBetween(coordinateOne, coordinateTwo)`
#### Arguments
| Argument | Type |
| -------- | ---- |
| coordinateOne | Object containing latitude and longitude key/value pairs |
| coordinateTwo | Object containing latitude and longitude key/value pairs |
** Latitude/longitude values should be degrees in decimal form
#### Returns
Distance between two coordinates in kilometers (KM). Distance is calculated via the Haversine formula.
## Credit(s)
https://www.movable-type.co.uk/scripts/latlong.html
https://en.wikipedia.org/wiki/Haversine_formula
## License
MIT License Copyright (c) 2018 Joel Colucci