toJson method

Map<String, dynamic> toJson()

Converts the GeoJsonFeatureCollection to a Map with keys 'type', 'bbox' and 'features'.

The 'bbox' key is converted to list of 4 doubles implying 2 coordinates.

Implementation

Map<String, dynamic> toJson() => <String, dynamic>{
      'type': 'FeatureCollection',
      'bbox': <double>[
        bbox[0].longitude,
        bbox[0].latitude,
        bbox[1].longitude,
        bbox[1].latitude,
      ],
      'features': features
          .map<Map<String, dynamic>>(
            (GeoJsonFeature feature) => feature.toJson(),
          )
          .toList(),
    };