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
a3ef2ca7
Commit
a3ef2ca7
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: partial shape seleciton
parent
5311a658
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
Clhp map
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/pages/widgets/cloropleth_map.dart
+15
-22
15 additions, 22 deletions
app/lib/pages/widgets/cloropleth_map.dart
with
15 additions
and
22 deletions
app/lib/pages/widgets/cloropleth_map.dart
+
15
−
22
View file @
a3ef2ca7
import
'dart:typed_data'
;
import
'../marker_handler/marker_data.dart'
;
import
'package:flutter/material.dart'
;
import
'package:syncfusion_flutter_maps/maps.dart'
;
import
'dart:math'
;
import
'
dart:conve
rt'
;
import
'
../marker_handler/marker_data.da
rt'
;
/// A class containing thickness data for each subdivision of the map.
class
IceThicknessModel
{
IceThicknessModel
(
this
.
sub_div_id
,
this
.
thickness
,
this
.
color
);
IceThicknessModel
(
this
.
sub_div_id
,
this
.
thickness
,
this
.
color
,
this
.
isSelected
);
final
String
sub_div_id
;
final
int
thickness
;
final
Color
color
;
Color
color
;
bool
isSelected
;
}
/// ChoroplethMap is a stateful widget that contains a choropleth map.
/// The map is created using the Syncfusion Flutter Maps library and
/// coordinates fetched from the server.
class
ChoroplethMap
extends
StatefulWidget
{
const
ChoroplethMap
({
Key
?
key
,
const
ChoroplethMap
({
Key
?
key
,
required
this
.
relation
,
required
this
.
measurements
required
this
.
measurements
,
})
:
super
(
key:
key
);
final
Uint8List
relation
;
...
...
@@ -31,11 +32,10 @@ class ChoroplethMap extends StatefulWidget {
}
class
_ChoroplethMapState
extends
State
<
ChoroplethMap
>
{
int
selectedIndex
=
-
1
;
late
MapShapeSource
mapShapeSource
;
late
final
MapZoomPanBehavior
_zoomPanBehavior
=
MapZoomPanBehavior
();
List
<
IceThicknessModel
>
iceThicknessList
=
<
IceThicknessModel
>[];
List
<
Color
>
testColors
=
[
// NB test color
List
<
Color
>
testColors
=
[
const
Color
(
0xff8a003b
),
const
Color
(
0xff8a4300
),
const
Color
(
0xff8a7a00
),
...
...
@@ -53,7 +53,7 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
Color
randomColor
=
testColors
[
ran
];
int
randomNumber
=
random
.
nextInt
(
21
);
// 0 -> 20, NB: temp test data
iceThicknessList
.
add
(
IceThicknessModel
(
i
.
toString
(),
randomNumber
,
randomColor
));
iceThicknessList
.
add
(
IceThicknessModel
(
i
.
toString
(),
randomNumber
,
randomColor
,
false
));
}
}
...
...
@@ -64,29 +64,23 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
SfMaps
(
layers:
[
MapShapeLayer
(
source
:
MapShapeSource
.
memory
(
// Map polygon
widget
.
relation
,
// JSON coordinates from server
source
:
MapShapeSource
.
memory
(
widget
.
relation
,
shapeDataField:
'sub_div_id'
,
dataCount:
iceThicknessList
.
length
,
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
;
for
(
int
i
=
0
;
i
<
iceThicknessList
.
length
;
i
++
)
{
iceThicknessList
[
i
]
.
isSelected
=
i
==
index
;
iceThicknessList
[
i
]
.
color
=
i
==
index
?
Colors
.
red
:
iceThicknessList
[
i
]
.
color
;
}
});
print
(
"Selection triggered"
);
},
selectionSettings:
MapSelectionSettings
(
color:
Colors
.
orange
,
strokeColor:
Colors
.
red
[
900
],
strokeWidth:
3
,
),
),
],
),
...
...
@@ -94,4 +88,3 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
);
}
}
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