From e424a1ca7951adc438a2e15f83173c7e51373a97 Mon Sep 17 00:00:00 2001 From: Sara <sarasdj@stud.ntnu.no> Date: Thu, 8 Feb 2024 13:36:08 +0100 Subject: [PATCH] update: dynamic alloction of markers --- app/lib/main.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/lib/main.dart b/app/lib/main.dart index 19c96b55..a64af293 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -52,6 +52,11 @@ class DefaultPage extends StatefulWidget { 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), + ]; // Timer initializer @override @@ -81,6 +86,7 @@ class _DefaultPageState extends State<DefaultPage> { double screenWidth = MediaQuery.of(context).size.width; double boxWidth = 0.9; double boxHeight = 1.5; + const double markerSize = 40; return Scaffold( appBar: AppBar( @@ -105,6 +111,24 @@ class _DefaultPageState extends State<DefaultPage> { urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", subdomains: ['a', 'b', 'c'], ), + MarkerLayer( + markers: locations + .map( + (LatLng location) => Marker( + width: 80.0, + height: 80.0, + point: location, + builder: (ctx) => Container( + child: Icon( + Icons.location_on, + color: Colors.blue, + size: 50.0, + ), + ), + ), + ) + .toList(), + ), ], ), ), -- GitLab