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
58fbb5ca
Commit
58fbb5ca
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: InteractivePolygon
parent
2d6d1f8e
No related branches found
Branches containing commit
No related tags found
1 merge request
!3
Choropleth map implementation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/pages/widgets/cloropleth_map.dart
+33
-0
33 additions, 0 deletions
app/lib/pages/widgets/cloropleth_map.dart
app/lib/pages/widgets/interactive_polygon.dart
+9
-26
9 additions, 26 deletions
app/lib/pages/widgets/interactive_polygon.dart
with
42 additions
and
26 deletions
app/lib/pages/widgets/cloropleth_map.dart
0 → 100644
+
33
−
0
View file @
58fbb5ca
import
'package:flutter/material.dart'
;
import
'../marker_handler/marker_data.dart'
;
// From https://www.syncfusion.com/blogs/post/create-choropleth-map-using-in-flutter.aspx
class
_ChoroplethMapState
extends
State
{
List
<
Measurement
>
iceThickness
;
MapShapeSource
_mapShapeSource
;
@override
void
initState
()
{
super
.
initState
();
_mapShapeSource
=
MapShapeSource
.
asset
(
'assets/world_map.json'
,
shapeDataField:
'name'
,
dataCount:
_mapShapeSource
.
length
,
primaryValueMapper:
(
int
index
)
=
>
_mapShapeSource
[
index
]
.
countryName
,
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
SfMaps
(
layers:
[
MapShapeLayer
(
source
:
_mapShapeSource
,
strokeColor:
Colors
.
white30
),
],
)
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/lib/pages/widgets/interactive_polygon.dart
+
9
−
26
View file @
58fbb5ca
...
...
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import
'../marker_handler/marker_data.dart'
;
import
'package:latlong2/latlong.dart'
as
latLng
;
// InteractivePolygon returns a Polygon
object wrapped
in a CustomPaint,
//
which is then wrapped in a GestureDetector. This is
in order to make the
P
olygon clickable
// InteractivePolygon returns a Polygon in a CustomPaint,
in a GestureDetector
// in order to make the
p
olygon clickable
class
InteractivePolygon
extends
StatelessWidget
{
final
List
<
latLng
.
LatLng
>
points
;
final
void
Function
(
Measurement
)
?
onTap
;
...
...
@@ -34,8 +34,8 @@ class InteractivePolygon extends StatelessWidget {
}
}
// PolygonPainter
takes the points, color, and stroke width from a
//
object of type InteractivePolygon, and renders it
// PolygonPainter
is a custom polygon renderer for Measurement objects
//
NB: from https://www.kindacode.com/article/flutter-custompaint-and-custompainter/
class
PolygonPainter
extends
CustomPainter
{
final
List
<
latLng
.
LatLng
>
points
;
final
Color
bodyColor
;
...
...
@@ -69,6 +69,11 @@ class PolygonPainter extends CustomPainter {
final
path
=
Path
();
if
(
points
.
isNotEmpty
)
{
print
(
"
\n
"
);
for
(
final
coord
in
points
)
{
print
(
"Corner:
${coord.latitude}
,
${coord.longitude}
"
);
}
final
firstPoint
=
points
.
first
;
path
.
moveTo
(
firstPoint
.
latitude
,
firstPoint
.
longitude
);
...
...
@@ -84,28 +89,6 @@ class PolygonPainter extends CustomPainter {
else
{
print
(
"Error in rendering polygon. No points provided"
);
}
/*final paint = Paint()
..color = color
..style = PaintingStyle.stroke
..strokeWidth = strokeWidth;
final path = Path();
if (points.isNotEmpty) {
final firstPoint = points.first;
path.moveTo(firstPoint.latitude, firstPoint.longitude);
for (var i = 1; i < points.length; i++) {
final point = points[i];
path.lineTo(point.latitude, point.longitude);
}
path.close();
canvas.drawPath(path, paint);
}
else {
print("Error in rendering polygon. No points provided");
}*/
}
@override
...
...
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