https://github.com/joduplessis/distancer
Lightweight utility library for measuring the distance between 2 GPS points.
https://github.com/joduplessis/distancer
location rollup typescript
Last synced: about 1 month ago
JSON representation
Lightweight utility library for measuring the distance between 2 GPS points.
- Host: GitHub
- URL: https://github.com/joduplessis/distancer
- Owner: joduplessis
- License: mit
- Created: 2018-02-25T10:58:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-26T09:11:10.000Z (over 7 years ago)
- Last Synced: 2024-12-26T00:23:08.980Z (6 months ago)
- Topics: location, rollup, typescript
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Distancer
## Lightweight utility library for measuring the distance between 2 GPS points.### Installation
Install the package via GitHub with `npm install https://github.com/joduplessis/Distancer.git` or `yarn add https://github.com/joduplessis/Distancer.git`.
### Usage
This example assumes ES6 usage.
```
import { Distancer } from 'distancer';// Instantiate the class
const distancer = new Distancer();// Set your origin
distancer.setOrigin({
lat: -29.8483609,
lon: 30.9224223,
});// Set your destination
distancer.setDestination({
lat: 53.5765144,
lon: 9.9716112,
});// This could be "M" (miles) or "K" (kilometers)
distancer.setMetric("K")// How far it is
const distance: number = distancer.calculateDistance();console.log("The distance from your location:", distance);
```