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

dix: coloroed map on app

parent 8fd3d49d
No related branches found
No related tags found
1 merge request!7Clhp map
......@@ -7,10 +7,11 @@ import 'dart:convert';
/// A class containing thickness data for each subdivision of the map.
class IceThicknessModel {
IceThicknessModel(this.subDivID, this.thickness);
IceThicknessModel(this.sub_div_id, this.thickness, this.color);
final String subDivID;
final String sub_div_id;
final int thickness;
final Color color;
}
/// ChoroplethMap is a stateful widget that contains a choropleth map.
......@@ -30,6 +31,7 @@ class ChoroplethMap extends StatefulWidget {
}
class _ChoroplethMapState extends State<ChoroplethMap> {
int selectedIndex = -1;
late MapShapeSource mapShapeSource;
late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior();
List<IceThicknessModel> iceThicknessList = <IceThicknessModel>[];
......@@ -39,9 +41,15 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
super.initState();
final Random random = Random();
for (int i = 0; i <= 60; i++) {
for (int i = 0; i <= 120; i++) {
int red = random.nextInt(256);
int green = random.nextInt(256);
int blue = random.nextInt(256);
Color randomColor = Color.fromRGBO(red, green, blue, 1);
int randomNumber = random.nextInt(21); // 0 -> 20, NB: temp test data
iceThicknessList.add(IceThicknessModel(i.toString(), randomNumber));
iceThicknessList.add(IceThicknessModel(i.toString(), randomNumber, randomColor));
}
}
......@@ -54,14 +62,27 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
MapShapeLayer(
source: MapShapeSource.memory( // Map polygon
widget.relation, // JSON coordinates from server
shapeDataField: 'properties.sub_div_id',
shapeDataField: 'sub_div_id',
dataCount: iceThicknessList.length,
primaryValueMapper: (int index) => iceThicknessList[index].subDivID,
shapeColorValueMapper: (int index) => iceThicknessList[index].thickness,
primaryValueMapper: (int index) => iceThicknessList[index].sub_div_id,
shapeColorValueMapper: (int index) => iceThicknessList[index].color,
),
//color: Colors.blue.shade400, // Map color
//zoomPanBehavior: _zoomPanBehavior,
//strokeColor: Colors.black,
// Shape selection
selectedIndex: selectedIndex,
onSelectionChanged: (int index) {
setState(() {
selectedIndex = index;
});
print("Selection triggered");
},
selectionSettings: MapSelectionSettings(
color: Colors.orange,
strokeColor: Colors.red[900],
strokeWidth: 3,
),
color: Colors.blue.shade400, // Map color
zoomPanBehavior: _zoomPanBehavior,
strokeColor: Colors.black,
),
],
),
......
No preview for this file type
......@@ -28,6 +28,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water
divided_map.extend(combine_grid_with_poly(polygon, lines))
'''
####################### PLOTTIND ############################
tiles = [gpd.GeoDataFrame(geometry=[tile]) for tile in divided_map]
......@@ -44,6 +45,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water
plt.show()
##################### PLOTTIND END ###########################
'''
features = []
......@@ -62,7 +64,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water
tile_feature = {
'type': 'Feature',
'properties': {
'sub_div_id': sub_div_id,
'sub_div_id': str(sub_div_id),
'sub_div_center': center
},
'geometry': rounded_tile.__geo_interface__
......
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