GeoJson.fromJson constructor

GeoJson.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory GeoJson.fromJson(Map<String, dynamic> json) {
  if (!json.containsKey('type')) {
    throw Exception('Missing type on GeoJson');
  }
  if (json['type'] == _$GeoJsonTypeEnumMap[GeoJsonType.feature]) {
    return GeoJson(feature: GeoJsonFeature.fromJson(json));
  } else if (json['type'] == _$GeoJsonTypeEnumMap[GeoJsonType.featureCollection]) {
    return GeoJson(featureCollection: GeoJsonFeatureCollection.fromJson(json));
  } else {
    throw Exception('Invalid type "${json['key']}" on GeoJson');
  }
}