PHPackages                             emcconville/polyline-encoder - 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/polyline-encoder

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

emcconville/polyline-encoder
============================

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

v1.1.1(11y ago)30260.2k↓11%41GNUPHPPHP &gt;=5.4

Since Mar 23Pushed 11y ago4 watchersCompare

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

READMEChangelog (2)DependenciesVersions (5)Used By (1)

Polyline Encoder
================

[](#polyline-encoder)

[![Build Status](https://camo.githubusercontent.com/c4c8aaf1330b0f7cf54ec0c27b16d70f99f53bd9f68d84c967a1ea70ff8ced98/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f656d63636f6e76696c6c652f706f6c796c696e652d656e636f6465722e706e67)](http://travis-ci.org/emcconville/polyline-encoder)[![Latest Stable Version](https://camo.githubusercontent.com/24f10cf6edfcf367a2bb607e5640dc0c4f68561d1cd872d26392d095cdaf8311/68747470733a2f2f706f7365722e707567782e6f72672f656d63636f6e76696c6c652f706f6c796c696e652d656e636f6465722f762f737461626c652e706e67)](https://packagist.org/packages/emcconville/polyline-encoder)[![License](https://camo.githubusercontent.com/a7f31e0b007b1a7046842b687a526e53bc6efbf443ad60ddb2d9fdd95cb44832/68747470733a2f2f706f7365722e707567782e6f72672f656d63636f6e76696c6c652f706f6c796c696e652d656e636f6465722f6c6963656e73652e706e67)](https://packagist.org/packages/emcconville/polyline-encoder)

Formerly [emcconville/google-map-polyline-encoding-tool](https://github.com/emcconville/google-map-polyline-encoding-tool), this library provides encoding/decoding methods for Google Map's [Encoded Polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm), and Microsoft's [Point Compression Algorithm](http://msdn.microsoft.com/en-us/library/jj158958.aspx). The intent of the [Polyline Encoder](https://github.com/emcconville/polyline-encoder) library is to shift the core algorithms to PHP Traits over traditional class implementations.

Installation
------------

[](#installation)

Add `emcconville/polyline-encoder` to composer's required list.

```
{
  "require" : {
    "emcconville/polyline-encoder" : "1.*"
  }
}
```

Follow basic composer installation &amp; guide.

```
curl -sS https://getcomposer.org/installer | php
./composer.phar install
```

Usage
-----

[](#usage)

Both `BingTrait` &amp; `GoogleTrait` cover the same two methods.

*string* &lt;object&gt;**::encodePoints**( *array* $points )

```
// Convert list of points into encoded string.
$points = [
  [41.89084,-87.62386],
  [41.89086,-87.62279],
  [41.89028,-87.62277],
  [41.89028,-87.62385],
  [41.89084,-87.62386]
];

$googleObject->encodePoints($points); //=> "wxt~Fd`yuOCuErBC?vEoB@"
$bingObject->encodePoints($points);   //=> "yg7qol5jxJjqX3iH01W5sG"
```

*array* &lt;object&gt;**::decodeString**( *string* $string )

```
// Restore list from encode string.
$points = $googleObject->decodeString("wxt~Fd`yuOCuErBC?vEoB@");
$points[3]; //=> array(41.89028,-87.62385)
$points = $bingObject->decodeString("yg7qol5jxJjqX3iH01W5sG");
$points[4]; //=> array(41.89084,-87.62386)
```

### Goolge Map

[](#goolge-map)

```
// Apply Google Trait.
class MyGooglePolyline
{
  use emcconville\Polyline\GoogleTrait;
}
```

### Bing Map

[](#bing-map)

```
// Apply Bing Trait.
class MyBingPolyline
{
  use emcconville\Polyline\BingTrait;
}
```

### OSRM Map

[](#osrm-map)

```
// Apply Google Trait with precision overwrite.
class MyProjectOsrmPolyline
{
  use emcconville\Polyline\GoogleTrait;

  /**
   * Implement precision method in sub-class.
   * @return int
   */
  public function polylinePrecision()
  {
      return 6;
  }
}
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~45 days

Total

4

Last Release

4301d 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 (24 commits)")

---

Tags

googlecompressionmapspointpolylinebing

### Embed Badge

![Health badge](/badges/emcconville-polyline-encoder/health.svg)

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

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k8.6M22](/packages/mjaschen-phpgeo)[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)[emcconville/google-map-polyline-encoding-tool

A simple class to handle polyline-encoding for Google Maps

1572.3M2](/packages/emcconville-google-map-polyline-encoding-tool)[arcanedev/seo-helper

SEO Helper is a framework agnostic package that provides tools &amp; helpers for SEO (Laravel supported).

332467.0k4](/packages/arcanedev-seo-helper)

PHPackages © 2026

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