GeoJSONLineString.fromMap constructor
Constructs a GeoJSONLineString from a Map.
Implementation
factory GeoJSONLineString.fromMap(Map<String, dynamic> map) {
assert(map.containsKey('type'), 'There MUST be contains key `type`');
assert(['LineString'].contains(map['type']), 'Invalid type');
assert(map.containsKey('coordinates'),
'There MUST be contains key `coordinates`');
assert(map['coordinates'] is List,
'There MUST be array of two or more positions.');
final lll = map['coordinates'];
final coordinates = <List<double>>[];
lll.forEach((ll) {
assert(ll is List, 'There MUST be List');
assert((ll as List).length > 1, 'There MUST be two or more element');
final pos = ll.map((e) => e.toDouble()).cast<double>().toList();
coordinates.add(pos);
});
return GeoJSONLineString(coordinates);
}