FMGeoJsonModel.fromJSON constructor
FMGeoJsonModel.fromJSON(
- Map<String, dynamic> data
)
Implementation
factory FMGeoJsonModel.fromJSON(Map<String, dynamic> data) {
final List<FMGeocodeModel> coordinates = [];
final type = '${data['type']}'.geocodeJsonType;
switch (type) {
case FMGeocodeJsonType.point:
coordinates.add(FMGeocodeModel(
'${data['coordinates'][0]}',
'${data['coordinates'][1]}',
));
break;
case FMGeocodeJsonType.polygon:
final l = (data['coordinates'][0] as List?)
?.map((e) => FMGeocodeModel('${e[0]}', '${e[1]}'));
if (l != null) coordinates.addAll(l);
break;
default:
}
return FMGeoJsonModel(type: type, coordinates: coordinates);
}