encode static method

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

Encodes a sequence of LatLngs into an encoded path string.

Implementation

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

  final StringBuffer result = StringBuffer();

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

    int dLat = lat - lastLat;
    int dLng = lng - lastLng;

    _encode(dLat, result);
    _encode(dLng, result);

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