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