Polyline
Simple utility library for dealing with JSON polylines
Installation
To use with a module bundler like webpack:
npm install --save polyline-coordinates
Usage
const Polyline = ; // the polyline needs to be an array of [latitude, longitude] valuesconst polyline = Polyline polyline// 347.618 miles polyline// 559.43555212 km polyline;// [35.91355, 120.33155]
API
Polyline.createLine(geojson)
Creates a new polyline instance with the json representation of a polyline.
Polyline.getDistanceBetweenPoints(start, end)
Returns the distance in miles between two coordinates.
Polyline.getDistanceBetweenPointsKm(start, end)
Returns the distance in kilometers between two coordinates.
.getLengthInMiles()
Returns the total distance covered by the polyline in miles.
.getLengthInKm()
Returns the total distance covered by the polyline in kilometers.
.getPointCovering(percent)
Returns the coordinate of the point that covers the percentage of the polyline specified.
For example .getPointCovering(0.5)
will return the coordinates of the point
that is located in the middle of the polyline.