featuresFromGeoJson function

Future<GeoJsonFeatureCollection> featuresFromGeoJson(
  1. String data, {
  2. String? nameProperty,
  3. bool verbose = false,
})

Get a feature collection from a geojson string

Implementation

Future<GeoJsonFeatureCollection> featuresFromGeoJson(String data,
    {String? nameProperty, bool verbose = false}) async {
  final featureCollection = GeoJsonFeatureCollection();
  final geojson = GeoJson();
  try {
    await geojson.parse(data, nameProperty: nameProperty, verbose: verbose);
  } catch (e) {
    rethrow;
  }
  geojson.features.forEach((f) => featureCollection.collection!.add(f));
  geojson.dispose();
  return featureCollection;
}