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
76790c2f
Commit
76790c2f
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: dynamic allocation of marker color and size
parent
e424a1ca
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Server
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/main.dart
+25
-15
25 additions, 15 deletions
app/lib/main.dart
with
25 additions
and
15 deletions
app/lib/main.dart
+
25
−
15
View file @
76790c2f
...
...
@@ -4,6 +4,7 @@ import 'package:latlong2/latlong.dart'; // Import LatLng class from the latlong
import
'dart:async'
;
import
'dart:io'
;
const
String
port
=
"8443"
;
const
String
serverURI
=
"https://127.0.0.1:
$port
/"
;
const
String
mapEndpoint
=
"update_map"
;
...
...
@@ -50,12 +51,21 @@ class DefaultPage extends StatefulWidget {
_DefaultPageState
createState
()
=
>
_DefaultPageState
();
}
class
MarkerData
{
final
LatLng
location
;
final
double
size
;
final
Color
color
;
MarkerData
({
required
this
.
location
,
required
this
.
size
,
required
this
.
color
});
}
class
_DefaultPageState
extends
State
<
DefaultPage
>
{
late
Timer
_timer
;
final
List
<
LatLng
>
locations
=
[
LatLng
(
60.8366
,
10.8171
),
LatLng
(
60.7366
,
10.8471
),
LatLng
(
60.7266
,
10.9771
),
final
List
<
MarkerData
>
markerList
=
[
MarkerData
(
location:
LatLng
(
60.7266
,
10.9771
),
size:
50.0
,
color:
Colors
.
blue
),
MarkerData
(
location:
LatLng
(
60.8366
,
10.8171
),
size:
70.0
,
color:
Colors
.
red
),
MarkerData
(
location:
LatLng
(
60.7366
,
10.8471
),
size:
60.0
,
color:
Colors
.
green
),
];
// Timer initializer
...
...
@@ -103,26 +113,26 @@ class _DefaultPageState extends State<DefaultPage> {
color:
Colors
.
blue
,
child:
FlutterMap
(
options:
MapOptions
(
center:
LatLng
(
60.7666
,
10.8471
),
// Initial center of the map (latitude and longitude)
zoom:
9.0
,
// Initial zoom level of the map
center:
LatLng
(
60.7666
,
10.8471
),
zoom:
9.0
,
),
children:
[
// Add layers directly as children
children:
[
TileLayer
(
urlTemplate:
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
,
subdomains:
[
'a'
,
'b'
,
'c'
],
),
MarkerLayer
(
markers:
locations
MarkerLayer
(
// Dynamically allocate markers based on a list
markers:
markerList
.
map
(
(
LatLng
location
)
=
>
Marker
(
width:
80.0
,
height:
80.0
,
point:
location
,
(
MarkerData
markerData
)
=
>
Marker
(
width:
markerData
.
size
,
height:
markerData
.
size
,
point:
markerData
.
location
,
builder:
(
ctx
)
=
>
Container
(
child:
Icon
(
Icons
.
location_on
,
color:
Colors
.
blue
,
size:
50.0
,
color:
markerData
.
color
,
size:
markerData
.
size
,
),
),
),
...
...
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