diff --git a/lib/genericMap.dart b/lib/genericMap.dart index 3618315..85a354f 100644 --- a/lib/genericMap.dart +++ b/lib/genericMap.dart @@ -156,7 +156,7 @@ class _genericMapState extends State { // print('${positionCallback.center}, ${positionCallback.zoom}'); //} ); - var mapController = new MapController(); + // var mapController = new MapController(); // mapController.fitBounds(bounds); // mapController.center @@ -402,14 +402,17 @@ class _genericMapState extends State { List markers = []; print( 'building markers: fires: ${fires.length} falsePos: ${falsePosList.length} industries: ${industries.length}, isNotif: $isNotif '); - const calibrate = false; // useful when we change the fire icons size + // const calibrate = false; // useful when we change the fire icons size falsePosList.forEach((falsePos) { try { - var coords = falsePos['geo']['coordinates']; + var coords = falsePos['geo']['coordinates'] as List; // print('false pos: ${coords}'); - var loc = LatLng(coords[1].toDouble(), coords[0].toDouble()); - markers.add(FireMarker(loc, FireMarkType.falsePos)); - if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); + var loc = LatLng( + (coords[1] as num).toDouble(), (coords[0] as num).toDouble()); + markers.add(FireMarker(loc, FireMarkType.falsePos, () { + _showFalsePositiveDialog(loc); + })); + // if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); } catch (e, stackTrace) { print('Failed to process $falsePos'); reportError(e, stackTrace); @@ -418,10 +421,13 @@ class _genericMapState extends State { industries.forEach((industry) { try { // print(fire['geo']['coordinates']); - var coords = industry['geo']['coordinates']; - var loc = LatLng(coords[1], coords[0]); - markers.add(FireMarker(loc, FireMarkType.industry)); - if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); + var coords = industry['geo']['coordinates'] as List; + var loc = LatLng( + (coords[1] as num).toDouble(), (coords[0] as num).toDouble()); + markers.add(FireMarker(loc, FireMarkType.industry, () { + _showIndustryDialog(loc); + })); + // if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); } catch (e, stackTrace) { print('Failed to process $industry'); reportError(e, stackTrace); @@ -429,9 +435,11 @@ class _genericMapState extends State { }); fires.forEach((fire) { try { - var loc = new LatLng(fire['lat'], fire['lon']); + var loc = new LatLng( + (fire['lat'] as num).toDouble(), (fire['lon'] as num).toDouble()); markers.add(FireMarker(loc, FireMarkType.fire, () { - onFirePressed(loc, DateTime.parse(fire['when']), fire['type']); + onFirePressed(loc, DateTime.parse(fire['when'].toString()), + (fire['type'] as String)); print('fire $fire pressed'); })); markers.add(FireMarker(loc, FireMarkType.pixel)); @@ -442,7 +450,7 @@ class _genericMapState extends State { }); markers.add( FireMarker(pos, isNotif ? FireMarkType.fire : FireMarkType.position)); - if (calibrate) markers.add(FireMarker(pos, FireMarkType.pixel)); + // if (calibrate) markers.add(FireMarker(pos, FireMarkType.pixel)); return markers; } @@ -470,4 +478,50 @@ class _genericMapState extends State { )); }); } + + void _showIndustryDialog(LatLng pos) { + getReverseLocation(lat: pos.latitude, lon: pos.longitude) + .then((reverseLoc) { + String industryDesc = '${S.of(context).itSeemsAIndustry}\n\n' + 'Type: Industry\n' + 'Location: $reverseLoc'; + showDialog( + context: _scaffoldKey.currentContext!, + builder: (_) => new AlertDialog( + title: Text(S.of(context).notAWildfire), + content: new Text(industryDesc), + actions: [ + new TextButton( + child: Text(S.of(context).CLOSE), + onPressed: () { + Navigator.pop(context); + }, + ), + ], + )); + }); + } + + void _showFalsePositiveDialog(LatLng pos) { + getReverseLocation(lat: pos.latitude, lon: pos.longitude) + .then((reverseLoc) { + String falseDesc = '${S.of(context).itSeemsNotAtForesFire}\n\n' + 'Type: False Positive\n' + 'Location: $reverseLoc'; + showDialog( + context: _scaffoldKey.currentContext!, + builder: (_) => new AlertDialog( + title: Text(S.of(context).notAWildfire), + content: new Text(falseDesc), + actions: [ + new TextButton( + child: Text(S.of(context).CLOSE), + onPressed: () { + Navigator.pop(context); + }, + ), + ], + )); + }); + } }