GeoJSONPoint.fromMap constructor

GeoJSONPoint.fromMap(
  1. Map<String, dynamic> map
)

Constructs a GeoJSONPoint from a Map.

Implementation

factory GeoJSONPoint.fromMap(Map<String, dynamic> map) {
  assert(map.containsKey('type'), 'There MUST be contains key `type`');
  assert(['Point'].contains(map['type']), 'Invalid type');
  assert(map.containsKey('coordinates'),
      'There MUST be contains key `coordinates`');
  assert(map['coordinates'] is List, 'There MUST be List of double');
  final ll = map['coordinates'];
  assert((ll as List).length > 1, 'There MUST be two or more element');
  final pos = ll.map((e) => e.toDouble()).cast<double>().toList();
  return GeoJSONPoint(pos);
}