Search packages, repositories and app categories

Package detailsv3.1.0

google_polyline_algorithm

Dart implementation of Googles Polyline Encoding lossy compression Algorithm.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
29K
Likes
55
Pub points
160

Install package

flutter pub add google_polyline_algorithm

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Dart implementation of Google's Polyline Encoding algorithm, used to compress latitude and longitude coordinates into a compact string format. This lossy compression reduces data size for map paths, making it ideal for efficient transmission and storage in geolocation applications. The package supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. It enables developers to encode and decode polylines with minimal overhead, maintaining sufficient accuracy for most mapping use cases.

Use cases

  • Map route visualization
  • Efficient GPS data transmission
  • Compact storage of geographic paths
  • Real-time location tracking
  • Geospatial data sharing
  • Offline map data

Key features

  • Lossy coordinate compression
  • Cross-platform support
  • Simple encoding/decoding API
  • High performance
  • Accurate for typical map distances
  • Lightweight dependency

Suitable for

  • Mobile and web mapping apps
  • Location-based services
  • Route planning tools
  • Data-efficient geospatial APIs
  • Applications handling large GPS datasets

Considerations

  • Loss of precision due to compression
  • Not suitable for high-accuracy scientific measurements
  • Requires careful handling of edge cases in extreme latitudes
  • Limited to polyline-only geometry
  • May need validation for critical navigation systems

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

google_polyline_algorithm

Build codecov Pub GitHub GitHub stars

Dart implementation of Googles Polyline Encoding lossy compression Algorithm.

Getting Started

This package adds following methods to work with Googles Polyline Encoding Algorithm:

  • encodePoint(num current, {num previous = 0, int accuracyExponent = 5}) encodes a single coordinate

  • encodePolyline(List<List<num>> coordinates, {int accuracyExponent = 5}) encodes a list of coordinates into an encoded polyline stirng

  • decodePolyline(String polyline, {int accuracyExponent = 5}) decodes an encoded polyline string into a list of coordinates

Examples

import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';

final coord = encodePoint(-179.9832104);
print(coord);
// output is `~oia@'

final coords = encodePolyline([
  [38.5, -120.2],
  [40.7, -120.95],
  [43.252, -126.453],
]);
print(coords);
// output is `_p~iF~ps|U_ulLnnqC_mqNvxq`@'

final polyline = decodePolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
print(polyline);
// output is [[38.5, -120.2],[40.7, -120.95],[43.252, -126.453],]

Categories

Source repository

Projects using this package