PHPackages                             emcconville/google-map-polyline-encoding-tool - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. emcconville/google-map-polyline-encoding-tool

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

emcconville/google-map-polyline-encoding-tool
=============================================

A simple class to handle polyline-encoding for Google Maps

v1.3(10y ago)1572.3M—3%39[2 PRs](https://github.com/emcconville/google-map-polyline-encoding-tool/pulls)2GNUPHPPHP &gt;=5.3

Since Mar 17Pushed 2y ago8 watchersCompare

[ Source](https://github.com/emcconville/google-map-polyline-encoding-tool)[ Packagist](https://packagist.org/packages/emcconville/google-map-polyline-encoding-tool)[ RSS](/packages/emcconville-google-map-polyline-encoding-tool/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (8)Used By (2)

Google Maps Polyline Encoding Tool
==================================

[](#google-maps-polyline-encoding-tool)

[![Build Status](https://camo.githubusercontent.com/c844d808f794f48dfd42f304a6992df5ca950aa50f8e2abcaf5cf17f675fafc8/68747470733a2f2f7472617669732d63692e6f72672f656d63636f6e76696c6c652f676f6f676c652d6d61702d706f6c796c696e652d656e636f64696e672d746f6f6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/emcconville/google-map-polyline-encoding-tool)[![Coverage Status](https://camo.githubusercontent.com/bd9401a4de4586f4a01b3563874a3b58084b261c43723145382a9d753b5d9011/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f656d63636f6e76696c6c652f676f6f676c652d6d61702d706f6c796c696e652d656e636f64696e672d746f6f6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/emcconville/google-map-polyline-encoding-tool?branch=master)[![Packagist Version](https://camo.githubusercontent.com/d8ec8017ecef3032b2f24a5baa8a13d0f083ec64bcfdb05197924375e21f90e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d63636f6e76696c6c652f676f6f676c652d6d61702d706f6c796c696e652d656e636f64696e672d746f6f6c2e737667)](https://packagist.org/packages/emcconville/google-map-polyline-encoding-tool)

A simple PHP class for translating [polyline](http://code.google.com/apis/maps/documentation/javascript/reference.html#Polygon) into an [encoded](http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html) strings for Google Maps.

Install
-------

[](#install)

Use [composer](https://github.com/composer/composer).

```
$ curl -sS https://getcomposer.org/installer | php
$ cat > composer.json  wxt~Fd`yuOCuErBC?vEoB@
```

[![Tribune](https://camo.githubusercontent.com/13ee54e751c82fb619571121c3ba164ce83551a6294de34f4f44fc7ed73dbfd3/687474703a2f2f656d63636f6e76696c6c652e636f6d2f506f6c796c696e652f74726962756e652e706e67)](https://camo.githubusercontent.com/13ee54e751c82fb619571121c3ba164ce83551a6294de34f4f44fc7ed73dbfd3/687474703a2f2f656d63636f6e76696c6c652e636f6d2f506f6c796c696e652f74726962756e652e706e67)

### Decoding

[](#decoding)

```
// String to decode
$encoded = "kiw~FpoavObBA?fAzEC";

$points = Polyline::decode($encoded);
//=> array(
//     41.90374,-87.66729,41.90324,-87.66728,
//     41.90324,-87.66764,41.90214,-87.66762
//   );

// Or list of tuples
$points = Polyline::pair($points);
//=> array(
//     array(41.90374,-87.66729),
//     array(41.90324,-87.66728),
//     array(41.90324,-87.66764),
//     array(41.90214,-87.66762)
//   );
```

[![Records](https://camo.githubusercontent.com/a0c265a69d7c35c4aacf25bf03f48119856f315b6a553765029a14a571b49397/687474703a2f2f656d63636f6e76696c6c652e636f6d2f506f6c796c696e652f647573747967726f6f76652e706e67)](https://camo.githubusercontent.com/a0c265a69d7c35c4aacf25bf03f48119856f315b6a553765029a14a571b49397/687474703a2f2f656d63636f6e76696c6c652e636f6d2f506f6c796c696e652f647573747967726f6f76652e706e67)

Examples
--------

[](#examples)

See [examples](examples) directory for creative ideas, and please contribute new use-cases / hacks.

- [Well-Known Binary](examples/WellKnownBinary) converter.
- Preview encoded strings with a [SVG transcoder](examples/EncodedToSVG).

### Specify precision

[](#specify-precision)

Precision defaults to 1e-5 (0.00001) which is expected by Google Map API. Other API's like [OSRM](http://map.project-osrm.org/) expect a precision of 1e-6. You can adjust the precision you want by sub-classing Polyline, and overwrite the `$precision` static property.

```
class PolylineOSRM extends Polyline
{
    protected static $precision = 6;
}
$points = PolylineOSRM::decode($line);
$line = PolylineOSRM::encode($points);
```

**Caution**

- Adjusting the precision level will not guarantee improved accuracy. Existing issues with PHP's internal float point arithmetic can contribute accuracy issues.
- Third party libraries will not automatically know what level of precision was used during encoding.

Family
------

[](#family)

This library exists as a PHP reference point for Google's [Encoded Polyline Algorithm Format](http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html). There is also a [C implementation](https://github.com/emcconville/php_polyline), and a [namespace/trait library](https://github.com/emcconville/polyline-encoder) under active development.

Requires[google-map-polyline-encoding-tool](https://github.com/emcconville/google-map-polyline-encoding-tool)[polyline-encoder](https://github.com/emcconville/polyline-encoder)[php\_polyline](https://github.com/emcconville/php_polyline)PHP5.35.4C-APISupports[google-map-polyline-encoding-tool](https://github.com/emcconville/google-map-polyline-encoding-tool)[polyline-encoder](https://github.com/emcconville/polyline-encoder)[php\_polyline](https://github.com/emcconville/php_polyline)Google✔✔✔Bing✔Precision✔✔✔Tuple✔✔Traits✔Abstraction✔

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity58

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 89% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~149 days

Recently: every ~157 days

Total

6

Last Release

3696d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e6c723ba1f834133dd9a4ba54186905f7a6c93e6ea7fbe63c368c155eb7d4fb?d=identicon)[emcconville](/maintainers/emcconville)

---

Top Contributors

[![emcconville](https://avatars.githubusercontent.com/u/84594?v=4)](https://github.com/emcconville "emcconville (89 commits)")[![martinlindhe](https://avatars.githubusercontent.com/u/181531?v=4)](https://github.com/martinlindhe "martinlindhe (6 commits)")[![caseycs](https://avatars.githubusercontent.com/u/76095?v=4)](https://github.com/caseycs "caseycs (1 commits)")[![MiniCodeMonkey](https://avatars.githubusercontent.com/u/220535?v=4)](https://github.com/MiniCodeMonkey "MiniCodeMonkey (1 commits)")[![rodo](https://avatars.githubusercontent.com/u/85827?v=4)](https://github.com/rodo "rodo (1 commits)")[![heimpogo](https://avatars.githubusercontent.com/u/10332286?v=4)](https://github.com/heimpogo "heimpogo (1 commits)")[![DMeshkov-HORIS](https://avatars.githubusercontent.com/u/7288482?v=4)](https://github.com/DMeshkov-HORIS "DMeshkov-HORIS (1 commits)")

---

Tags

googlemaps

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/emcconville-google-map-polyline-encoding-tool/health.svg)

```
[![Health](https://phpackages.com/badges/emcconville-google-map-polyline-encoding-tool/health.svg)](https://phpackages.com/packages/emcconville-google-map-polyline-encoding-tool)
```

###  Alternatives

[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)[emcconville/polyline-encoder

PHP Traits algorithms for Encoded Polyline &amp; Bing Point Compression

30260.2k1](/packages/emcconville-polyline-encoder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
