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
b0240876
Commit
b0240876
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: recenter map
parent
fe2ce947
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
App2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/pages/widgets/map_widget.dart
+40
-1
40 additions, 1 deletion
app/lib/pages/widgets/map_widget.dart
with
40 additions
and
1 deletion
app/lib/pages/widgets/map_widget.dart
+
40
−
1
View file @
b0240876
...
...
@@ -24,6 +24,14 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
Measurement
?
selectedMarker
;
// Containing data for selected marker
bool
isMinimized
=
true
;
// Quick view box state tacker
bool
satLayer
=
false
;
// Satellite layer visibility tracker
bool
isTapped
=
false
;
// Button tap state tracker
final
MapController
_mapController
=
MapController
();
// Map controller to re-center map view
// recenterMap moves the map back to its initial view
void
recenterMap
()
{
_mapController
.
move
(
mapCenter
,
9.0
);
}
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -55,6 +63,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
center:
mapCenter
,
zoom:
9.0
,
),
mapController:
_mapController
,
children:
[
TileLayer
(
urlTemplate:
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
,
...
...
@@ -164,7 +173,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child:
GestureDetector
(
onTap:
()
{
setState
(()
{
isMinimized
=
!
isMinimized
;
// Toggle minimized state
//
isMinimized = !isMinimized; // Toggle minimized state
});
},
child:
Icon
(
isMinimized
?
Icons
.
arrow_drop_up
:
Icons
.
arrow_drop_down
),
...
...
@@ -194,6 +203,36 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
),
),
Positioned
(
// Back to center button
top:
45
,
right:
10
,
child:
GestureDetector
(
onTapDown:
(
_
)
{
setState
(()
{
recenterMap
();
// Reset map view
isTapped
=
true
;
});
},
onTapUp:
(
_
)
{
setState
(()
{
isTapped
=
false
;
});
},
onTapCancel:
()
{
setState
(()
{
isTapped
=
false
;
});
},
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8
),
decoration:
isTapped
?
const
BoxDecoration
(
// Add decoration only when pressed
shape:
BoxShape
.
circle
,
color:
Colors
.
blue
,
)
:
null
,
child:
const
Icon
(
Icons
.
settings_backup_restore
),
),
),
),
],
),
),
...
...
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