Skip to content
Snippets Groups Projects
Commit c44603db authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: tile selection in map widget, partial implementation

parent 47ba192c
No related branches found
No related tags found
1 merge request!7Clhp map
......@@ -21,11 +21,13 @@ class IceThicknessModel {
class ChoroplethMap extends StatefulWidget {
const ChoroplethMap({Key? key,
required this.relation,
required this.measurements
required this.measurements,
required this.onSelectionChanged,
}) : super(key: key);
final Uint8List relation;
final List<Measurement> measurements;
final void Function(int selectedIndex) onSelectionChanged; // Callback function
@override
_ChoroplethMapState createState() => _ChoroplethMapState();
......@@ -84,7 +86,7 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
iceThicknessList[i].color = i == index ? Colors.red : iceThicknessList[i].savedColor;
}
});
print("Selection triggered");
widget.onSelectionChanged(selectedIndex);
},
selectionSettings: MapSelectionSettings(
color: Colors.orange,
......
......@@ -28,6 +28,7 @@ class MapContainerWidget extends StatefulWidget {
class _MapContainerWidgetState extends State<MapContainerWidget> {
Measurement? selectedMarker; // Containing data for selected marker
int selectedMarkerIndex = 0;
bool isMinimized = true; // Quick view box state tacker
bool satLayer = false; // Satellite layer visibility tracker
bool isTapped = false; // Button tap state tracker
......@@ -53,10 +54,17 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
}
}
// Tile selection handler
void handleSelection(int index) {
setState(() {
selectedMarkerIndex = index;
});
}
@override
Widget build(BuildContext context) {
// Initialise selectedMarker to first element in markerList
selectedMarker ??= widget.markerList[0];
selectedMarker ??= widget.markerList[selectedMarkerIndex];
checkAndSetLastUpdate();
......@@ -154,7 +162,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
height: screenWidth * boxHeight,
child: Padding(
padding: const EdgeInsets.all(15.0), // Padding around map
child: ChoroplethMap(relation: widget.relation, measurements: widget.markerList,),
child: ChoroplethMap(
relation: widget.relation,
measurements: widget.markerList,
onSelectionChanged: handleSelection,),
),
),
Positioned( // Quick view box layered over map
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment