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

add: single test polygon

parent 68a4bfd9
No related branches found
No related tags found
1 merge request!2App2
......@@ -28,7 +28,7 @@ class Measurement {
cornerList: (json['Corners'] as List<dynamic>)
.map((data) => Corner.fromJson(data))
.toList(),
bodyOfWater: json['WaterBodyName'],
bodyOfWater: json['BodyOfWater'],
/*
dataList: (json['Data'] != null && json['Data'] is List)
? (json['Data'] as List<dynamic>).map((data) => Data.fromJson(data)).toList()
......
......@@ -46,7 +46,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
height: screenWidth * boxHeight,
child: OSMmap(markerList: widget.markerList), // OpenStreetMap layer
),
SizedBox(
/*SizedBox(
width: screenWidth * boxWidth,
height: screenWidth * boxHeight,
child: Stack(
......@@ -58,7 +58,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
),
],
),
),
),*/
Positioned( // Quick view box layered over map
bottom: 10,
right: 10,
......
......@@ -14,33 +14,37 @@ class OSMmap extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Init list of polygons
List<Polygon> polygons = [];
// Map each element from markerList to a measurement object
markerList.forEach((Measurement measurement) {
// Map corners to a list of LatLng objects
List<LatLng> points = measurement.cornerList.map((Corner corner) {
return LatLng(corner.latitude, corner.longitude);
}).toList();
Polygon polygon = Polygon(
points: points, // Use list of corner coordinates to render polygon
color: Colors.blue.withOpacity(0.5),
isFilled: true,
);
polygons.add(polygon); // Add each polygon to a list
});
return FlutterMap(
options: MapOptions(
center: mapCenter, // From consts
center: mapCenter,
zoom: 9.0,
),
children: [
TileLayer( // Map from OpenStreetMap
TileLayer(
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: const ['a', 'b', 'c'],
),
PolygonLayer( // Map each element in markerList to Measurement object
polygons: markerList.map((Measurement measurement) {
return Polygon(
points: measurement.cornerList.map((Corner corner) {
// Map corner coordinates to LatLng objects
return LatLng(corner.latitude, corner.longitude);
}).toList(),
/*onTap: () { NB: figure out how to make polygons interactive
setState(() {
selectedMarker = measurement;
});
},*/
color: Colors.blue,
isFilled: true,
);
}).toList(),
)
PolygonLayer(
polygons: polygons, // Return map with list of polygons included
),
],
);
}
......
No preview for this file type
......@@ -76,7 +76,7 @@ def get_all_markers(self, cursor, valid: bool):
},
'Data': [data_object],
'Corners': [corner_object],
'BodyOfWater' : row[14]
'BodyOfWater': row[14]
}
# Convert dictionary values to list of measurements
......@@ -103,4 +103,3 @@ def get_all_markers(self, cursor, valid: bool):
# Write marker data to response object
self.wfile.write(marker_data.encode('utf-8'))
No preview for this file type
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