Google Encoded Polyline Encoder
Encode [latitude, longitude] pairs into a Google encoded-polyline string using the standard delta and varint scheme.
Description
Compress ordered latitude/longitude pairs into Google's encoded-polyline text format.
Google Encoded Polyline Encoder compress ordered latitude/longitude pairs into Google's encoded-polyline text format.
Use this for compact route storage, interoperating with mapping APIs, or creating deterministic encoded geometry fixtures.
When to use Google Encoded Polyline Encoder
Use this for compact route storage, interoperating with mapping APIs, or creating deterministic encoded geometry fixtures.
How it works
Coordinates are rounded at the selected decimal precision, converted to deltas from the previous point, zigzag-transformed, and emitted in five-bit character chunks.1
Interpreting the result
Keep the input units, direction conventions, encoding, and ordering rules visible when reusing the result. Preserve the full returned value for downstream calculations and round only for presentation.
Assumptions and limitations
Encoding is lossy at the selected precision. Point order matters, and very large precision values can exceed safe integer arithmetic for coordinate deltas.
References
-
Encoded Polyline Algorithm Format — Google Maps Platform