glineenc /

Filename Size Date modified Message
317 B
90 B
453 B
48 B
1.1 KB
1.6 KB
6.5 KB
371 B


GLineEnc is a Google Maps Polyline Encoder--it encodes line geometries such that they can be rendered more efficiently in the browser.

The encoding algorithm is described here:


GLineEnc is packaged as a standard distutils distribution. It can be installed via easy_install, pip, python install, or by adding it to the install_requires list in your For example:

pip install glineenc


GLineEnc exposes a single API function, encode_pairs. This function accepts a sequence of latitude/longitude pairs and returns a string representing the encoded points and another string indicating the maximum zoom level at which each point should be displayed:

>>> from glineenc import encode_pairs
>>> result = encode_pairs([(38.5, -120.2), (43.252, -126.453)])
>>> result
('_p~iF~ps|U_c_\\fhde@', 'BB')

You could JSONify the result like this to pass it to the browser:

>>> import json
>>> json.dumps({'points': result[0], 'levels': result[1]})
'{"points": "_p~iF~ps|U_c_\\\\fhde@", "levels": "BB"}'

On the client, you would create a line from this encoded data like so:

// It's assumed here that you've decoded the JSON object created
// above into a local var named `result`.
var path = google.maps.geometry.encoding.decodePath(result.points);
var myLine = new google.maps.Polyline({path: path});

In Google Maps v2, that would look like this instead:

var myLine = new GPolyline.fromEncoded({
    points: result.points,
    levels: result.levels
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.