Simple utility library for dealing with JSON polylines
To use with a module bundler like webpack:
npm install --save polyline-coordinates
const Polyline = require('polyline-coordinates');
// the polyline needs to be an array of [latitude, longitude] values
const polyline = Polyline.createLine([[34.028337, -118.259954], [37.773566, -122.412786]])
polyline.getLengthInMiles()
// 347.618 miles
polyline.getLengthInKm()
// 559.43555212 km
polyline.getPointCovering(0.5);
// [35.91355, 120.33155]
Creates a new polyline instance with the json representation of a polyline.
Returns the distance in miles between two coordinates.
Returns the distance in kilometers between two coordinates.
Returns the total distance covered by the polyline in miles.
Returns the total distance covered by the polyline in kilometers.
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.