Skip to content

Exception when running example app #22

@ankelkoss

Description

@ankelkoss

lib>src>geojson_parser.dart : 307
Exception has occurred.
_TypeError (type 'int' is not a subtype of type 'double' in type cast)

before

for (final coords in path as List<dynamic>) {
   if (pathIndex == 0) {
     // add to polygon's outer ring
     outerRing.add(LatLng(coords[1] as double, coords[0] as double));
   } else {
     // add it to a hole
     hole.add(LatLng(coords[1] as double, coords[0] as double));
   }
}

after

for (final coords in path as List<dynamic>) {
      final double latitude = coords[1] is int ? (coords[1] as int).toDouble() : coords[1] as double;
      final double longitude = coords[0] is int ? (coords[0] as int).toDouble() : coords[0] as double;

      if (pathIndex == 0) {
        // add to polygon's outer ring
        outerRing.add(LatLng(latitude, longitude));
      } else {
        // add it to a hole
        hole.add(LatLng(latitude, longitude));
      }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions