encodeGeometry method
Encodes List<List<num>>
of coordinates
into a String
via
Encoded Polyline Algorithm Format
For mode detailed info about encoding refer to encodePoint
.
Implementation
String encodeGeometry({int precision = 5}) {
if (isEmpty) {
return "";
}
final factor = math.pow(10, precision);
var output =
_encode(this[0].lat, 0, factor) + _encode(this[0].lng, 0, factor);
for (var i = 1; i < length; i++) {
var current = this[i], previous = this[i - 1];
output += _encode(current.lat, previous.lat, factor);
output += _encode(current.lng, previous.lng, factor);
}
return output;
}