Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
e0f9cc5f
Commit
e0f9cc5f
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: minor improvement swapping lakes
parent
74bf5813
No related branches found
No related tags found
1 merge request
!13
Clhp map
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/pages/default_page.dart
+2
-0
2 additions, 0 deletions
app/lib/pages/default_page.dart
app/lib/widgets/choropleth_map.dart
+53
-41
53 additions, 41 deletions
app/lib/widgets/choropleth_map.dart
app/lib/widgets/main_layout.dart
+2
-2
2 additions, 2 deletions
app/lib/widgets/main_layout.dart
with
57 additions
and
43 deletions
app/lib/pages/default_page.dart
+
2
−
0
View file @
e0f9cc5f
...
@@ -6,6 +6,7 @@ import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';
...
@@ -6,6 +6,7 @@ import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';
import
'../consts.dart'
;
import
'../consts.dart'
;
import
'../widgets/main_layout.dart'
;
import
'../widgets/main_layout.dart'
;
import
'../widgets/choropleth_map.dart'
;
import
'../utils/custom_search_delegate.dart'
;
import
'../utils/custom_search_delegate.dart'
;
class
DefaultPage
extends
StatefulWidget
{
class
DefaultPage
extends
StatefulWidget
{
...
@@ -66,6 +67,7 @@ class _DefaultPageState extends State<DefaultPage> {
...
@@ -66,6 +67,7 @@ class _DefaultPageState extends State<DefaultPage> {
setState
(()
{
setState
(()
{
print
(
"SetState called!"
);
print
(
"SetState called!"
);
selectedLake
=
result
;
selectedLake
=
result
;
// NB update lastLake persistent variable
initialiseState
(
false
);
initialiseState
(
false
);
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/choropleth_map.dart
+
53
−
41
View file @
e0f9cc5f
...
@@ -9,7 +9,8 @@ import '../data_classes.dart';
...
@@ -9,7 +9,8 @@ import '../data_classes.dart';
/// The map is created using the Syncfusion Flutter Maps library and
/// The map is created using the Syncfusion Flutter Maps library and
/// coordinates fetched from the server.
/// coordinates fetched from the server.
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
,
required
this
.
onSelectionChanged
,
...
@@ -20,64 +21,75 @@ class ChoroplethMap extends StatefulWidget {
...
@@ -20,64 +21,75 @@ class ChoroplethMap extends StatefulWidget {
final
void
Function
(
int
selectedIndex
)
onSelectionChanged
;
final
void
Function
(
int
selectedIndex
)
onSelectionChanged
;
@override
@override
_
ChoroplethMapState
createState
()
=
>
_
ChoroplethMapState
();
ChoroplethMapState
createState
()
=
>
ChoroplethMapState
();
}
}
class
_
ChoroplethMapState
extends
State
<
ChoroplethMap
>
{
class
ChoroplethMapState
extends
State
<
ChoroplethMap
>
{
int
selectedIndex
=
-
1
;
// Subdivision/map tile index
int
selectedIndex
=
-
1
;
// Subdivision/map tile index
late
MapShapeSource
dataSource
;
late
MapShapeSource
dataSource
;
late
final
MapZoomPanBehavior
_zoomPanBehavior
=
MapZoomPanBehavior
();
late
final
MapZoomPanBehavior
_zoomPanBehavior
=
MapZoomPanBehavior
();
final
List
<
SubDiv
>
_subdivisions
=
<
SubDiv
>[];
final
List
<
SubDiv
>
_subdivisions
=
<
SubDiv
>[];
void
updateDataSource
()
{
_initDataSource
();
}
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// Extract all _subdivisions from list of measurements
_initDataSource
();
for
(
Measurement
measurement
in
widget
.
measurements
)
{
}
for
(
SubDiv
subdivision
in
measurement
.
subDivs
)
{
_subdivisions
.
add
(
subdivision
);
void
_initDataSource
()
{
_subdivisions
.
clear
();
// Extract all _subdivisions from list of measurements
for
(
Measurement
measurement
in
widget
.
measurements
)
{
for
(
SubDiv
subdivision
in
measurement
.
subDivs
)
{
_subdivisions
.
add
(
subdivision
);
}
}
}
};
// Initialise data source
dataSource
=
MapShapeSource
.
memory
(
dataSource
=
MapShapeSource
.
memory
(
widget
.
relation
,
widget
.
relation
,
shapeDataField:
'sub_div_id'
,
shapeDataField:
'sub_div_id'
,
dataCount:
_subdivisions
.
length
,
dataCount:
_subdivisions
.
length
,
primaryValueMapper:
(
int
index
)
=
>
_subdivisions
[
index
]
.
sub_div_id
,
primaryValueMapper:
(
int
index
)
=
>
_subdivisions
[
index
]
.
sub_div_id
,
shapeColorValueMapper:
(
int
index
)
=
>
_subdivisions
[
index
]
.
avgThickness
,
// NB will later be minThickness
shapeColorValueMapper:
(
int
index
)
=
>
_subdivisions
[
index
]
.
avgThickness
,
// NB will later be minThickness
shapeColorMappers:
const
[
shapeColorMappers:
const
[
MapColorMapper
(
from:
-
2
,
to:
-
1
,
color:
Color
(
0xFF8C8C8C
),
text:
'>8'
),
MapColorMapper
(
from:
0
,
to:
4
,
color:
Color
(
0xFFff0000
),
text:
'{0},{4}'
),
MapColorMapper
(
MapColorMapper
(
from:
-
2
,
from:
4
,
to:
-
1
,
to:
6
,
color:
Color
(
0xFF8C8C8C
),
color:
Color
(
0xffff6a00
),
text:
'6'
),
MapColorMapper
(
from:
6
,
to:
8
,
color:
Color
(
0xFFb1ff00
),
text:
'8'
),
MapColorMapper
(
from:
8
,
to:
400
,
color:
Color
(
0xFF00d6ff
),
text:
'>8'
),
text:
'>8'
),
MapColorMapper
(
],
from:
0
,
);
to:
4
,
color:
Color
(
0xFFff0000
),
text:
'{0},{4}'
),
MapColorMapper
(
from:
4
,
to:
6
,
color:
Color
(
0xffff6a00
),
text:
'6'
),
MapColorMapper
(
from:
6
,
to:
8
,
color:
Color
(
0xFFb1ff00
),
text:
'8'
),
MapColorMapper
(
from:
8
,
to:
400
,
color:
Color
(
0xFF00d6ff
),
text:
'>8'
),
],
);
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
updateDataSource
();
return
Stack
(
return
Stack
(
children:
[
children:
[
SfMapsTheme
(
SfMapsTheme
(
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/main_layout.dart
+
2
−
2
View file @
e0f9cc5f
...
@@ -75,7 +75,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -75,7 +75,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
// Initialise selectedMarker to first element in markerList
// Initialise selectedMarker to first element in markerList
selectedSubDiv
??=
widget
.
measurements
[
0
]
.
subDivs
[
0
];
selectedSubDiv
??=
widget
.
measurements
[
0
]
.
subDivs
[
0
];
checkAndSetLastUpdate
();
checkAndSetLastUpdate
();
const
double
contPadding
=
30
;
// Container padding space
const
double
contPadding
=
30
;
// Container padding space
...
@@ -107,7 +106,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -107,7 +106,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child:
ChoroplethMap
(
child:
ChoroplethMap
(
relation:
widget
.
relation
,
relation:
widget
.
relation
,
measurements:
widget
.
measurements
,
measurements:
widget
.
measurements
,
onSelectionChanged:
handleSelection
,),
onSelectionChanged:
handleSelection
,
),
),
),
),
),
SizedBox
(
SizedBox
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment