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