encode static method

String encode(
  1. List<Point<double>> path
)

Encodes a sequence of points into an encoded path string.

Uses the Encoded Polyline Algorithm.

Implementation

static String encode(final List<Point<double>> path) {
  int lastLat = 0;
  int lastLng = 0;

  final result = StringBuffer();

  for (final point in path) {
    final lat = (point.x * 1e5).round();
    final lng = (point.y * 1e5).round();

    _encode(lat - lastLat, result);
    _encode(lng - lastLng, result);

    lastLat = lat;
    lastLng = lng;
  }
  return result.toString();
}