GeoJSONFeatureCollection.fromMap constructor

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

The constructor from map.

Implementation

factory GeoJSONFeatureCollection.fromMap(Map<String, dynamic> map) {
  assert(map.containsKey('type'), 'There MUST be contains key `type`');
  assert(['FeatureCollection'].contains(map['type']), 'Invalid type');
  assert(
      map.containsKey('features'), 'There MUST be contains key `features`');
  assert(map['features'] is List, 'There MUST be an array of features.');
  final value = map['features'] as List;
  final fs = <GeoJSONFeature>[];
  Future.forEach(value, (map) {
    fs.add(GeoJSONFeature.fromMap(map as Map<String, dynamic>));
  });
  return GeoJSONFeatureCollection(fs);
}