LineString.fromJson constructor
Creates a LineString from a valid GeoJSON object
Example:
LineString.fromJson({'type': 'Feature', 'geometry': {'type': 'LineString', 'coordinates': [[1, 2], [3, 4]]}, 'properties': {}}); // LineString([Coordinate(1, 2), Coordinate(3, 4)])
Implementation
@override
factory LineString.fromJson(Map<String, dynamic> json) {
if (json['geometry']['type'] != 'LineString') {
throw ArgumentError('json is not a LineString');
}
return LineString(
(json['geometry']['coordinates'] as List<dynamic>)
.map((dynamic c) => Coordinate.fromJson(c))
.toList(),
properties: Map<String, dynamic>.from(json['properties']),
);
}