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
a00eeff8
Commit
a00eeff8
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: make map and box into separate widgets
parent
c36010ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/pages_and_widgets/default_page.dart
+104
-84
104 additions, 84 deletions
app/lib/pages_and_widgets/default_page.dart
with
104 additions
and
84 deletions
app/lib/pages_and_widgets/default_page.dart
+
104
−
84
View file @
a00eeff8
...
...
@@ -71,98 +71,118 @@ class _DefaultPageState extends State<DefaultPage> {
super
.
dispose
();
}
// Main widget
@override
Widget
build
(
BuildContext
context
)
{
double
screenWidth
=
MediaQuery
.
of
(
context
)
.
size
.
width
;
double
boxWidth
=
0.9
;
double
boxHeight
=
1.5
;
const
double
markerSize
=
20
;
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'IceMap
'
),
title:
Text
(
'My Page
'
),
),
body:
Center
(
child:
SingleChildScrollView
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Container
(
// Map container
width:
screenWidth
*
boxWidth
,
height:
screenWidth
*
boxHeight
,
color:
Colors
.
blue
,
child:
FlutterMap
(
options:
MapOptions
(
center:
LatLng
(
60.7666
,
10.8471
),
zoom:
9.0
,
),
children:
[
TileLayer
(
urlTemplate:
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
,
subdomains:
const
[
'a'
,
'b'
,
'c'
],
),
MarkerLayer
(
// Dynamically allocate markers based on a list
markers:
markerList
.
map
((
MarkerTemplate
MarkerTemplate
)
{
return
Marker
(
width:
MarkerTemplate
.
size
,
height:
MarkerTemplate
.
size
,
point:
MarkerTemplate
.
location
,
builder:
(
ctx
)
=
>
GestureDetector
(
onTap:
()
{
// NB: temporary print
print
(
'Icon tapped'
);
// NB: trigger function to add contents to the next box
},
child:
Image
.
asset
(
'assets/icons/circle-red.png'
,
// Path to your custom icon asset
color:
MarkerTemplate
.
color
,
width:
MarkerTemplate
.
size
,
height:
MarkerTemplate
.
size
,
),
),
);
})
.
toList
(),
),
/*PolygonLayer(
polygons: [
Polygon(
points: [
LatLng(60.7600, 10.8000),
LatLng(60.7600, 11.0000),
LatLng(60.7000, 11.0000),
LatLng(60.7000, 10.8000),
],
color: Colors.blue,
isFilled: true,
),
],
),*/
],
),
),
const
SizedBox
(
height:
20
),
Container
(
// Detailed info container
width:
screenWidth
*
boxWidth
,
height:
screenWidth
*
boxHeight
,
color:
Colors
.
blue
,
child:
const
Align
(
alignment:
Alignment
.
topLeft
,
child:
Padding
(
padding:
EdgeInsets
.
only
(
top:
10
,
left:
10
),
// Edge padding, text
child:
Text
(
'Placeholder text'
,
style:
TextStyle
(
fontSize:
20
,
color:
Colors
.
black
),
body:
ListView
(
children:
[
MapContainerWidget
(
markerList:
markerList
),
const
SizedBox
(
height:
30
),
// Padding between widgets
DetailedInfoContainerWidget
(),
],
),
);
}
}
class
MapContainerWidget
extends
StatelessWidget
{
final
List
<
MarkerTemplate
>
markerList
;
const
MapContainerWidget
({
super
.
key
,
required
this
.
markerList
});
@override
Widget
build
(
BuildContext
context
)
{
double
screenWidth
=
MediaQuery
.
of
(
context
)
.
size
.
width
;
double
boxWidth
=
0.9
;
double
boxHeight
=
1.5
;
return
Container
(
width:
screenWidth
*
boxWidth
,
height:
screenWidth
*
boxHeight
,
color:
Colors
.
blue
,
child:
FlutterMap
(
options:
MapOptions
(
center:
LatLng
(
60.7666
,
10.8471
),
zoom:
9.0
,
),
children:
[
TileLayer
(
urlTemplate:
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
,
subdomains:
const
[
'a'
,
'b'
,
'c'
],
),
MarkerLayer
(
markers:
markerList
.
map
((
MarkerTemplate
markerTemplate
)
{
return
Marker
(
width:
markerTemplate
.
size
,
height:
markerTemplate
.
size
,
point:
markerTemplate
.
location
,
builder:
(
ctx
)
=
>
GestureDetector
(
onTap:
()
{
// NB: temporary print
print
(
'Icon tapped'
);
// NB: trigger function to add contents to the next box
},
child:
Image
.
asset
(
'assets/icons/circle-red.png'
,
// Path to your custom icon asset
color:
markerTemplate
.
color
,
width:
markerTemplate
.
size
,
height:
markerTemplate
.
size
,
),
),
),
),
),
const
SizedBox
(
height:
20
),
],
);
})
.
toList
(),
),
),
/*PolygonLayer(
polygons: [
Polygon(
points: [
LatLng(60.7600, 10.8000),
LatLng(60.7600, 11.0000),
LatLng(60.7000, 11.0000),
LatLng(60.7000, 10.8000),
],
color: Colors.blue,
isFilled: true,
),
],
),*/
],
),
);
}
}
class
DetailedInfoContainerWidget
extends
StatelessWidget
{
const
DetailedInfoContainerWidget
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
double
screenWidth
=
MediaQuery
.
of
(
context
)
.
size
.
width
;
double
boxWidth
=
0.9
;
double
boxHeight
=
1.5
;
return
Container
(
width:
screenWidth
*
boxWidth
,
height:
screenWidth
*
boxHeight
,
color:
Colors
.
blue
,
child:
const
Align
(
alignment:
Alignment
.
topLeft
,
child:
Padding
(
padding:
EdgeInsets
.
only
(
top:
10
,
left:
10
),
// Edge padding, text
child:
Text
(
'Placeholder text'
,
style:
TextStyle
(
fontSize:
20
,
color:
Colors
.
black
),
),
),
),
);
}
}
\ No newline at end of file
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