encodePolyline static method
Encodes path into a Google-style polyline string.
Implementation
static String encodePolyline(List<LatLng> path, {int precision = 5}) {
if (path.isEmpty) {
return '';
}
final factor = math.pow(10, precision).toDouble();
final buffer = StringBuffer();
var lastLat = 0;
var lastLng = 0;
for (final point in path) {
final lat = (point.latitude * factor).round();
final lng = (point.longitude * factor).round();
_encodeValue(lat - lastLat, buffer);
_encodeValue(lng - lastLng, buffer);
lastLat = lat;
lastLng = lng;
}
return buffer.toString();
}