diff --git a/app/lib/widgets/choropleth_map.dart b/app/lib/widgets/choropleth_map.dart index 40043b983ab008631988268a293e293713fa10a1..11f8743cbdf0be2c064b3eb3c7bea3bb1f372615 100644 --- a/app/lib/widgets/choropleth_map.dart +++ b/app/lib/widgets/choropleth_map.dart @@ -34,22 +34,20 @@ class ChoroplethMap extends StatefulWidget { } class _ChoroplethMapState extends State<ChoroplethMap> { - late MapShapeSource dataSource; int selectedIndex = -1; + Color selectedColor = Colors.grey; // Initialise to gray + late MapShapeSource dataSource; late MapShapeSource mapShapeSource; late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior(); List<SubDiv> subdivisions = <SubDiv>[]; - int count = 0; - @override void initState() { super.initState(); - // Create list of all subdivisions + // Extract all subdivisions from list of measurements for (Measurement measurement in widget.measurements) { for (SubDiv subdivision in measurement.subDivs) { subdivisions.add(subdivision); - count++; } }; @@ -57,32 +55,32 @@ class _ChoroplethMapState extends State<ChoroplethMap> { dataSource = MapShapeSource.memory( widget.relation, shapeDataField: 'sub_div_id', - dataCount: count, + dataCount: subdivisions.length, primaryValueMapper: (int index) => subdivisions[index].sub_div_id, shapeColorValueMapper: (int index) => - subdivisions[index].avgThickness, + subdivisions[index].avgThickness, // NB will later be minThickness, fix in server first shapeColorMappers: const [ MapColorMapper( from: 0, to: 4, color: Color(0xFFff0000), - text: '{0},{25}'), + text: '{0},{4}'), MapColorMapper( from: 4, - to: 7, + to: 6, color: Color(0xffff6a00), - text: '75'), + text: '6'), MapColorMapper( - from: 7, - to: 10, + from: 6, + to: 8, color: Color(0xFFb1ff00), - text: '150'), + text: '8'), MapColorMapper( - from: 10, + from: 8, to: 400, - color: Color(0xff4fa8d7), - text: '400'), + color: Color(0xFF00d6ff), + text: '>8'), ], ); } @@ -92,8 +90,8 @@ class _ChoroplethMapState extends State<ChoroplethMap> { return Stack( children: [ SfMapsTheme( - data: SfMapsThemeData( // Shape selection behavior - selectionColor: Colors.orange, + data: SfMapsThemeData( // Coloring of selected shape + selectionColor: selectedColor, selectionStrokeWidth: 3, selectionStrokeColor: Colors.red[900], ), @@ -101,13 +99,14 @@ class _ChoroplethMapState extends State<ChoroplethMap> { layers: [ MapShapeLayer( source: dataSource, - //zoomPanBehavior: _zoomPanBehavior, + zoomPanBehavior: _zoomPanBehavior, strokeColor: Colors.blue.shade50, // Shape selection selectedIndex: selectedIndex, - onSelectionChanged: (int index) { - setState(() { // Shape selection + onSelectionChanged: (int index) { // Shape selection behavior + setState(() { selectedIndex = index; + selectedColor = subdivisions[index].color.withOpacity(0.7); }); widget.onSelectionChanged(selectedIndex); }, diff --git a/server/map/__pycache__/get_markers.cpython-311.pyc b/server/map/__pycache__/get_markers.cpython-311.pyc index 52efde446f4acf064a28ea6968ca718795092912..3f63d643f06eeb64a6fe464b5c5d0c837867dd3e 100644 Binary files a/server/map/__pycache__/get_markers.cpython-311.pyc and b/server/map/__pycache__/get_markers.cpython-311.pyc differ diff --git a/server/map/get_markers.py b/server/map/get_markers.py index 15c4b2332d2b16bc042514899d4a1cbc8f3a34de..e3f02a6278d383dda372a5ae3850279299d53d40 100644 --- a/server/map/get_markers.py +++ b/server/map/get_markers.py @@ -85,7 +85,7 @@ def get_all_markers(self, cursor, waterBodyName): 'CenLatitude': 7.0, 'CenLongitude': 8.0, 'Accuracy': 1.0, - 'Color': calculateColor(min_thickness) + 'Color': calculateColor(avg_thickness) } sub_divisions.append(subdivision) @@ -134,7 +134,7 @@ def calculateColor(thickness: float): # NB not final colors nor ranges if 0 < thickness <= 4: return 0xFFff0000 # Red elif 4 < thickness <= 6: - return 0xFFff9400 # Orange + return 0xffff6a00 # Orange elif 6 < thickness <= 8: return 0xFFb1ff00 # Green elif thickness > 8: