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

merge: app2

parents 6a2369ef 266b7e33
No related branches found
No related tags found
1 merge request!1Server
app/assets/icons/marker.png

4.7 KiB

......@@ -40,8 +40,9 @@ class MarkerData {
final LatLng location;
final double size;
final Color color;
final Radius radius;
MarkerData({required this.location, required this.size, required this.color});
MarkerData({required this.location, required this.size, required this.color, required this.radius});
}
// parseMarkerData parses jsonData into an object of type MakerData
......@@ -51,6 +52,7 @@ List<MarkerData> parseMarkerData(String jsonString) {
location: LatLng(data['latitude'], data['longitude']),
size: data['size'].toDouble(),
color: parseColor(data['color']),
radius: data['radius'].toDouble(),
)));
}
......@@ -126,7 +128,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;
const double markerSize = 20;
return Scaffold(
appBar: AppBar(
......@@ -151,22 +153,42 @@ class _DefaultPageState extends State<DefaultPage> {
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subdomains: const ['a', 'b', 'c'],
),
MarkerLayer( // Dynamically allocate markers based on a list
markers: markerList
.map(
(MarkerData markerData) => Marker(
MarkerLayer(
// Dynamically allocate markers based on a list
markers: markerList.map((MarkerData markerData) {
return Marker(
width: markerData.size,
height: markerData.size,
point: markerData.location,
builder: (ctx) => Icon(
Icons.favorite,
color: markerData.color,
size: markerData.size,
builder: (ctx) => GestureDetector(
onTap: () {
// NB: temporary print
print('Icon tapped');
// NB: trigger function to add contents to the next box
},
child: Icon(
Icons.circle,
color: markerData.color,
size: markerSize,
),
),
),
)
.toList(),
);
}).toList(),
),
/*PolygonLayer(
polygons: [
Polygon(
points: [
LatLng(60.7600, 10.8000),
LatLng(60.7600, 11.0000),
LatLng(60.7000, 11.0000),
LatLng(60.7000, 10.8000),
],
color: Colors.blue,
isFilled: true,
),
],
),*/
],
),
),
......
......@@ -22,3 +22,6 @@ dev_dependencies:
flutter:
uses-material-design: true
assets:
- assets/icons/marker.png
No preview for this file type
......@@ -23,15 +23,17 @@ class DataPoint:
# Template for map marker data
class MarkerTemplate:
def __init__(self, latitude, longitude, size, color):
def __init__(self, latitude, longitude, size, color, radius):
self.latitude = latitude
self.longitude = longitude
self.size = size
self.color = color
self. radius = radius
def to_dict(self):
return {
'latitude': self.latitude,
'longitude': self.longitude,
'size': self.size,
'color': self.color
'color': self.color,
'radius': self.radius
}
\ No newline at end of file
......@@ -31,13 +31,13 @@ class IceHTTP(BaseHTTPRequestHandler):
self.end_headers()
self.wfile.write(b"Root path hit!")
elif self.path == '/update_map':
# Send the response with a status code (e.g., 200 for success)
self.send_response(200)
markers_data, resp_code = get_markers()
self.send_response(resp_code)
self.send_header("Content-type", "application/json")
self.end_headers()
# Write the JSON data directly to the response
markers_data = get_markers()
self.wfile.write(markers_data.encode('utf-8'))
elif self.path == '/test_endpoint':
......
No preview for this file type
......@@ -6,13 +6,17 @@ sys.path.append(parent_dir)
from data_structs import MarkerTemplate
from flask import json
# get_markers parses a list of MarkerTemplate objects to json, and returns either a successfully
# parsed json object with status code 200, or and error message and status code 501
def get_markers():
testData = [
MarkerTemplate(latitude=60.7266, longitude=10.9771, size=50.0, color='blue'),
MarkerTemplate(latitude=60.8366, longitude=10.8171, size=70.0, color='red'),
MarkerTemplate(latitude=60.7366, longitude=10.8471, size=60.0, color='green'),
]
# Return jsonified marker list
return json.dumps([marker.to_dict() for marker in testData])
try:
testData = [
MarkerTemplate(latitude=60.7266, longitude=10.9771, size=30.0, color='blue', radius=10.0),
MarkerTemplate(latitude=60.8366, longitude=10.8171, size=20.0, color='red', radius=8.0),
MarkerTemplate(latitude=60.7366, longitude=10.8471, size=10.0, color='green', radius = 14.0),
]
return json.dumps([marker.to_dict() for marker in testData]), 200
except Exception as e:
return e, 500
\ No newline at end of file
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