Skip to content
Snippets Groups Projects
Commit 68799d9e authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: polygons instead of markers

parent 1874f684
No related branches found
No related tags found
No related merge requests found
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:latlong2/latlong.dart';
// API variables
const String port = "8443";
......@@ -7,6 +8,9 @@ const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map";
const int fetchInterval = 60; // Fetch marker data every n minutes
// Map center
LatLng mapCenter = LatLng(60.7666, 10.8471);
// Font variables
const textColor = Colors.white;
final appTitleStyle = GoogleFonts.dmSans(
......
......@@ -43,7 +43,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
height: screenWidth * boxHeight,
child: FlutterMap(
options: MapOptions(
center: LatLng(60.7666, 10.8471),
center: mapCenter, // From consts
zoom: 9.0,
),
children: [
......@@ -51,28 +51,23 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: const ['a', 'b', 'c'],
),
MarkerLayer(
markers: widget.markerList.map((Measurement Measurement) {
return Marker(
width: 50,
height: 50,
point: LatLng(Measurement.dataList[0].latitude, Measurement.dataList[0].longitude),
builder: (ctx) => GestureDetector(
onTap: () {
setState(() {
selectedMarker = Measurement;
});
},
child: Image.asset(
'assets/icons/circle-red.png',
color: Colors.red,
width: 50,
height: 50,
),
),
PolygonLayer( // Map each element in markerList to Measurement object
polygons: widget.markerList.map((Measurement measurement) {
return Polygon(
points: measurement.cornerList.map((Corner corner) {
// Match corners to LatLng objects
return LatLng(corner.latitude, corner.longitude);
}).toList(),
/*onTap: () {
setState(() {
selectedMarker = measurement;
});
},*/
color: Colors.blue,
isFilled: true,
);
}).toList(),
),
)
],
),
),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment