GeomLine.fromGeojson constructor

GeomLine.fromGeojson(
  1. Map<String, dynamic> inputJson, {
  2. bool withInvertedCoords = false,
})

Implementation

GeomLine.fromGeojson(Map<String, dynamic> inputJson, {bool withInvertedCoords = false}) {
  List<LatLng> finalCoordinates = [];
  String? type = inputJson['type'];

  if(type != 'LineString') {
    points = [];
  }

  // Gestion des LineString
  if (type == 'LineString') {
    final List coordinates = inputJson['coordinates'];
    for (var coord in coordinates) {
      final lat = coord[0].toDouble();
      final lon = coord[1].toDouble();
      finalCoordinates.add(withInvertedCoords ? LatLng(lon, lat) : LatLng(lat, lon));
    }
  }
  points = finalCoordinates;
}