Flexible Polyline encoding: a lossy compressed representation of a list of coordinate pairs or triples
npm install @here/flexpolylineThe flexible polyline encoding is a lossy compressed representation of a list of coordinate pairs or
coordinate triples.
For a detailed description, please visit GitHub.
To encode a polyline:
``js
import { encode } from '@here/flexpolyline';
// Define an array of coordinates
const coordinates = [
[50.1022829, 8.6982122],
[50.1020076, 8.6956695],
[50.1006313, 8.6914960],
[50.0987800, 8.6875156]
];
// encode the polyline
const flexPolyline = encode({ polyline: coordinates });
// The output should be the flex polyline "BFoz5xJ67i1B1B7PzIhaxL7Y"
console.log(flexPolyline);
`
To decode a polyline:
`js
import { decode } from '@here/flexpolyline';
// Use "decode" to get back the coordinates from the sample above
const decoded = decode(flexPolyline);
console.log(decoded.polyline);
``
Copyright (C) 2024 HERE Europe B.V.
See the LICENSE file in the root of this project for license details.