distance-location
v1.0.4
Published
A simple package to calculate distance between two coordinates
Downloads
11
Readme
calculate distance between two points / coordinates. It is different with google distance matrix which is calculate distance based on routes. This package calculate the length of one line from a point to another point in the earth.
Installation
npm install --save distance-location
Usage
var dist = distance.between(coordinate1, coordinate2, [unit])
Types / Params
coordinate = {
lat: Number,
lng: Number
}
unit 'km'
(default) | 'm'
. Unit is optional, if you don't supply the param, the default param 'km' will be used.
unit = 'km' (default)
unit = 'm'
Example
var distance = require('distance-location')
location1 = {
lat: -7.2606503,
lng: 112.7349606
}
location2 = {
lat: -7.2630689,
lng: 112.7355421
}
var dist = distance.between(location1, location2, 'm')
console.log(dist)