MultiPointField.fromJson constructor

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

Parse the incoming json and return a MultiPointField Usage, assuming that u parse a incoming json source, then the runtime type is a _InternalLinkedHashMap: MultiPointField.fromJson(Map<String, dynamic>.from(elem'location'))

Implementation

factory MultiPointField.fromJson(Map<String, dynamic> json) {
  /// Create a variable with the type of the Field, to reconstruct the incoming json data.
  String type = json['type'];

  /// Create a variable with a list of a list with coordinates.
  List<List<double>?> coordinates = [];

  /// Loop over the coordinates and add them to the coordinates list.
  json['coordinates'].forEach((elem) {
    coordinates.add(elem.cast<double>());
  });

  /// Return a [MultiPointField] with the variables [type] and [coordinates]
  return MultiPointField(
    type: type,
    coordinates: coordinates
  );
}