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

add: setLastLake()

parent f1ac7d22
No related branches found
No related tags found
1 merge request!13Clhp map
......@@ -3,13 +3,13 @@ import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:app/consts.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../consts.dart';
import '../data_classes.dart';
import '../server_requests/fetch_markers.dart';
import '../server_requests/fetch_relation.dart';
/// initialiseState makes three requests to the server, one requesting
/// measurements for the selected relation, the other requesting the relation,
/// and the last requesting the list of all system lakes
......@@ -31,6 +31,7 @@ Future<void> initialiseState(bool fetchSearchOptions) async {
markerListFuture = fetchMeasurements().then((fetchResult) {
List<Measurement> measurements = fetchResult.measurements;
serverConnection = fetchResult.connected;
setLastLake();
// Return measurements
return measurements;
......@@ -87,4 +88,9 @@ Future<void> initSearchOptions() async {
} catch (e) {
print("Failed to fetch lake names: $e");
}
}
Future<void> setLastLake() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString('lastLake', selectedLake);
}
\ No newline at end of file
......@@ -17,15 +17,15 @@ class ChoroplethMap extends StatefulWidget {
final Uint8List relation;
final List<Measurement> measurements;
final void Function(int _selectedIndex) onSelectionChanged;
final void Function(int selectedIndex) onSelectionChanged;
@override
ChoroplethMapState createState() => ChoroplethMapState();
_ChoroplethMapState createState() => _ChoroplethMapState();
}
class ChoroplethMapState extends State<ChoroplethMap> {
int _selectedIndex = -1; // Subdivision/map tile index
late MapShapeSource _dataSource;
class _ChoroplethMapState extends State<ChoroplethMap> {
int selectedIndex = -1; // Subdivision/map tile index
late MapShapeSource dataSource;
late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior();
final List<SubDiv> _subdivisions = <SubDiv>[];
......@@ -40,7 +40,7 @@ class ChoroplethMapState extends State<ChoroplethMap> {
};
// Initialise data source
_dataSource = MapShapeSource.memory(
dataSource = MapShapeSource.memory(
widget.relation,
shapeDataField: 'sub_div_id',
dataCount: _subdivisions.length,
......@@ -88,17 +88,17 @@ class ChoroplethMapState extends State<ChoroplethMap> {
child: SfMaps(
layers: [
MapShapeLayer(
source: _dataSource,
source: dataSource,
zoomPanBehavior: _zoomPanBehavior,
strokeColor: Colors.blue.shade50,
strokeWidth: 1,
// Shape selection
selectedIndex: _selectedIndex,
selectedIndex: selectedIndex,
onSelectionChanged: (int index) {
setState(() {
_selectedIndex = index;
selectedIndex = index;
});
widget.onSelectionChanged(_selectedIndex);
widget.onSelectionChanged(selectedIndex);
},
),
],
......
......@@ -138,7 +138,8 @@ def fill_remaining_subdivisions(lake_name: str, sub_div_ids: list):
'CenLatitude': center_lat,
'CenLongitude': center_lng,
'Accuracy': None,
'Color': calculateColor(ice_stats[0]['Total ice (m)']), # Calculate ice thickness based on total ice, temporary
# Calculate ice thickness based on total ice, temporary
'Color': calculateColor(ice_stats[0]['Total ice (m)']),
'IceStats': ice_stats,
}
......
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