guillaumegmt / polyline-encoder

Polyline Encoder / Decoder in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polyline Encoder

Polyline Encoder is a simple PHP class that will help you work with polyline encoding / decoding. For more details about the polyline encoder algorithm, please refer to : https://developers.google.com/maps/documentation/utilities/polylinealgorithm

License

This project is under MIT and GPLv2 Licenses.

Usage

Just insert the following line at the top of your PHP file :

#require_once 'PolylineEncoder.php';

Encode a polyline

To encode a polyline just follow those steps :

$polylineEncoder = new PolylineEncoder();

$polylineEncoder->addPoint(30.5,-120.2);
$polylineEncoder->addPoint(40.7,-120.95);
$polylineEncoder->addPoint(43.252,-126.453);

$encodedString = $polylineEncoder->encodedString();

Decode a polyline

$decodedPoints = PolylineEncoder::decodeString("_p~iF~ps|U_ulLnnqC_mqNvxq`@");

Note

Please note that the encoding levels are currently not supported.

About

Polyline Encoder / Decoder in PHP

License:GNU General Public License v2.0