decode static method

List<LatLng> decode(
  1. String encoded
)

Decodes a Google-encoded polyline string into a list of LatLng.

Implementation

static List<LatLng> decode(String encoded) {
  // First try precision 1e5; if out-of-range, retry with 1e6 (Polyline6)
  List<LatLng> pts = _decodeWithPrecision(encoded, 1e5);
  bool outOfRange = false;
  for (final p in pts) {
    if (p.latitude.abs() > 90.0 || p.longitude.abs() > 180.0) { outOfRange = true; break; }
  }
  if (outOfRange) {
    pts = _decodeWithPrecision(encoded, 1e6);
  }
  return pts;
}