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
8e8b08aa
Commit
8e8b08aa
authored
10 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
add: map re-renctering button, not tested
parent
dfa69ddb
No related branches found
Branches containing commit
No related tags found
1 merge request
!19
Clhp map, license agreement
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/widgets/choropleth_map.dart
+8
-0
8 additions, 0 deletions
app/lib/widgets/choropleth_map.dart
app/lib/widgets/main_layout.dart
+48
-6
48 additions, 6 deletions
app/lib/widgets/main_layout.dart
with
56 additions
and
6 deletions
app/lib/widgets/choropleth_map.dart
+
8
−
0
View file @
8e8b08aa
...
@@ -28,6 +28,8 @@ class ChoroplethMap extends StatefulWidget {
...
@@ -28,6 +28,8 @@ class ChoroplethMap extends StatefulWidget {
}
}
class
ChoroplethMapState
extends
State
<
ChoroplethMap
>
{
class
ChoroplethMapState
extends
State
<
ChoroplethMap
>
{
late
final
GlobalKey
<
ChoroplethMapState
>
_choroplethMapKey
=
GlobalKey
();
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
();
...
@@ -36,6 +38,12 @@ class ChoroplethMapState extends State<ChoroplethMap> {
...
@@ -36,6 +38,12 @@ class ChoroplethMapState extends State<ChoroplethMap> {
_initDataSource
();
_initDataSource
();
}
}
void
resetZoom
()
{
setState
(()
{
_choroplethMapKey
.
currentState
?.
resetZoom
();
});
}
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/main_layout.dart
+
48
−
6
View file @
8e8b08aa
...
@@ -32,19 +32,20 @@ class MapContainerWidget extends StatefulWidget {
...
@@ -32,19 +32,20 @@ class MapContainerWidget extends StatefulWidget {
}
}
class
_MapContainerWidgetState
extends
State
<
MapContainerWidget
>
{
class
_MapContainerWidgetState
extends
State
<
MapContainerWidget
>
{
// Button state trackers
bool
isMinimized
=
true
;
// Quick view box state tacker
bool
isMinimized
=
true
;
// Quick view box state tacker
bool
satLayer
=
false
;
// Satellite layer visibility state
bool
satLayer
=
false
;
// Satellite layer visibility state
bool
osmLayer
=
false
;
// OSM layer visibility state
bool
osmLayer
=
false
;
// OSM layer visibility state
bool
isSatTapped
=
false
;
// Satellite button tap state tracker
bool
isSatTapped
=
false
;
// Satellite button tap state tracker
bool
isMapTapped
=
false
;
// OSM button tap state tracker
bool
isMapTapped
=
false
;
// OSM button tap state tracker
bool
infoLayer
=
false
;
// Additional color information visibility
bool
centerMap
=
false
;
// Map centering button state tracker
bool
infoLayer
=
false
;
// Additional color legend visibility
// Initialise selected measurement to arbitrary value
Measurement
?
selectedMeasurement
=
selectedMeasurements
[
0
];
Measurement
?
selectedMeasurement
=
selectedMeasurements
[
0
];
final
GlobalKey
<
ChoroplethMapState
>
_choroplethMapKey
=
GlobalKey
();
// Initialise lastUpdate variable from persistent storage if server fetch fails
//
/
Initialise lastUpdate variable from persistent storage if server fetch fails
Future
<
void
>
checkAndSetLastUpdate
()
async
{
Future
<
void
>
checkAndSetLastUpdate
()
async
{
if
(
lastUpdate
==
null
)
{
if
(
lastUpdate
==
null
)
{
final
prefs
=
await
SharedPreferences
.
getInstance
();
final
prefs
=
await
SharedPreferences
.
getInstance
();
...
@@ -76,6 +77,13 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -76,6 +77,13 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
});
});
}
}
/// Reset the map zoom and centering
void
resetZoom
()
{
setState
(()
{
_choroplethMapKey
.
currentState
?.
resetZoom
();
});
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
// Initialise selectedMarker to first element in markerList
// Initialise selectedMarker to first element in markerList
...
@@ -109,6 +117,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -109,6 +117,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
child:
Padding
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
15.0
),
// Padding around map
padding:
const
EdgeInsets
.
all
(
15.0
),
// Padding around map
child:
ChoroplethMap
(
child:
ChoroplethMap
(
key:
_choroplethMapKey
,
relation:
widget
.
relation
,
relation:
widget
.
relation
,
measurements:
widget
.
measurements
,
measurements:
widget
.
measurements
,
subdivisions:
widget
.
subdivisions
,
subdivisions:
widget
.
subdivisions
,
...
@@ -227,9 +236,42 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
...
@@ -227,9 +236,42 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
),
),
),
),
),
Positioned
(
//
Color info
button
Positioned
(
//
Recenter map
button
top:
130
,
top:
130
,
right:
10
,
right:
10
,
child:
GestureDetector
(
onTapDown:
(
_
)
{
setState
(()
{
centerMap
=
true
;
});
},
onTapUp:
(
_
)
{
setState
(()
{
centerMap
=
false
;
});
resetZoom
();
// Reset the map zoom
},
onTapCancel:
()
{
setState
(()
{
centerMap
=
false
;
});
},
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8
),
decoration:
centerMap
?
const
BoxDecoration
(
// Add decoration only while pressed
shape:
BoxShape
.
circle
,
color:
Colors
.
grey
,
)
:
null
,
child:
const
Icon
(
Icons
.
center_focus_strong
,
color:
Colors
.
white54
,
),
),
),
),
Positioned
(
// Color info button
top:
170
,
right:
10
,
child:
GestureDetector
(
child:
GestureDetector
(
onTap:
()
{
onTap:
()
{
setState
(()
{
setState
(()
{
...
...
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