# polyline

> Polyline encoding and decoding

Latest version **0.2.0** (published 2015-08-04) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install polyline
pnpm add polyline
yarn add polyline
bun add polyline
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-08-04 |
| First published | 2012-07-26 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/polyline) |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 675 |
| Author | Tom MacWright |
| Maintainers | tmcw, jfirebaugh, mapbox |

## Links

- npm: https://www.npmjs.com/package/polyline
- Repository: https://github.com/mapbox/polyline
- Issues: https://github.com/mapbox/polyline/issues
- npm.io page: https://npm.io/package/polyline

## Recent versions

- 0.2.0 (latest) — 2015-08-04
- 0.1.0 — 2015-06-21
- 0.0.3 — 2013-12-17
- 0.0.2 — 2013-12-10
- 0.0.1 — 2013-12-09
- 0.0.0 — 2012-07-26

## README

[![Build Status](https://secure.travis-ci.org/mapbox/polyline.png?branch=master)](http://travis-ci.org/mapbox/polyline) [![Coverage Status](https://coveralls.io/repos/mapbox/polyline/badge.svg)](https://coveralls.io/r/mapbox/polyline)

# polyline

A simple [google-esque polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
implementation in Javascript. Compatible with nodejs (`npm install polyline` and the browser (copy `src/polyline.js`)).

Encodes/decodes into lat/lng coordinate pairs. Use `fromGeoJSON()` to encode from GeoJSON objects.

## Installation

    npm install polyline

## Example

```js
var polyline = require('polyline');

// returns an array of lat, lon pairs
polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@');

// returns a string-encoded polyline
polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]);

// returns a string-encoded polyline from a GeoJSON LineString
polyline.fromGeoJSON({ "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [[-120.2, 38.5], [-120.95, 40.7], [-126.453, 43.252]]
  },
  "properties": {}
});
```

# [Documentation](https://github.com/mapbox/polyline/blob/master/API.md)

## See Also

* [polyline algorithm](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
* [Mark McClure's Google Maps Project](http://facstaff.unca.edu/mcmcclur/GoogleMaps.html)
* [Routing geometry decoder in project-osrm](https://github.com/Project-OSRM/osrm-frontend/blob/master/WebContent/routing/OSRM.RoutingGeometry.js)

---
_Source: https://npm.io/package/polyline · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
