GeoJSONGeometryCollection.fromMap constructor

GeoJSONGeometryCollection.fromMap(
  1. Map<String, dynamic> map
)

Constructs a new Geometry Collection from a Map object.

The Map must represent a valid Geometry Collection.

Implementation

factory GeoJSONGeometryCollection.fromMap(Map<String, dynamic> map) {
  assert(map.containsKey('type'), 'There MUST be contains key `type`');
  assert(['GeometryCollection'].contains(map['type']), 'Invalid type');
  assert(map.containsKey('geometries'),
      'There MUST be contains key `geometries`');
  assert(map['geometries'] is List, 'There MUST be array of the geometry.');
  final value = map['geometries'];
  final geoms = <GeoJSONGeometry>[];
  value.forEach((map) {
    geoms.add(GeoJSONGeometry.fromMap(map));
  });
  return GeoJSONGeometryCollection(geoms);
}