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 { ...@@ -40,8 +40,9 @@ class MarkerData {
final LatLng location; final LatLng location;
final double size; final double size;
final Color color; 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 // parseMarkerData parses jsonData into an object of type MakerData
...@@ -51,6 +52,7 @@ List<MarkerData> parseMarkerData(String jsonString) { ...@@ -51,6 +52,7 @@ List<MarkerData> parseMarkerData(String jsonString) {
location: LatLng(data['latitude'], data['longitude']), location: LatLng(data['latitude'], data['longitude']),
size: data['size'].toDouble(), size: data['size'].toDouble(),
color: parseColor(data['color']), color: parseColor(data['color']),
radius: data['radius'].toDouble(),
))); )));
} }
...@@ -126,7 +128,7 @@ class _DefaultPageState extends State<DefaultPage> { ...@@ -126,7 +128,7 @@ class _DefaultPageState extends State<DefaultPage> {
double screenWidth = MediaQuery.of(context).size.width; double screenWidth = MediaQuery.of(context).size.width;
double boxWidth = 0.9; double boxWidth = 0.9;
double boxHeight = 1.5; double boxHeight = 1.5;
const double markerSize = 40; const double markerSize = 20;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -151,22 +153,42 @@ class _DefaultPageState extends State<DefaultPage> { ...@@ -151,22 +153,42 @@ class _DefaultPageState extends State<DefaultPage> {
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( // Dynamically allocate markers based on a list MarkerLayer(
markers: markerList // Dynamically allocate markers based on a list
.map( markers: markerList.map((MarkerData markerData) {
(MarkerData markerData) => Marker( return Marker(
width: markerData.size, width: markerData.size,
height: markerData.size, height: markerData.size,
point: markerData.location, point: markerData.location,
builder: (ctx) => Icon( builder: (ctx) => GestureDetector(
Icons.favorite, onTap: () {
color: markerData.color, // NB: temporary print
size: markerData.size, 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: ...@@ -22,3 +22,6 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
assets:
- assets/icons/marker.png
No preview for this file type
...@@ -23,15 +23,17 @@ class DataPoint: ...@@ -23,15 +23,17 @@ class DataPoint:
# Template for map marker data # Template for map marker data
class MarkerTemplate: class MarkerTemplate:
def __init__(self, latitude, longitude, size, color): def __init__(self, latitude, longitude, size, color, radius):
self.latitude = latitude self.latitude = latitude
self.longitude = longitude self.longitude = longitude
self.size = size self.size = size
self.color = color self.color = color
self. radius = radius
def to_dict(self): def to_dict(self):
return { return {
'latitude': self.latitude, 'latitude': self.latitude,
'longitude': self.longitude, 'longitude': self.longitude,
'size': self.size, '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): ...@@ -31,13 +31,13 @@ class IceHTTP(BaseHTTPRequestHandler):
self.end_headers() self.end_headers()
self.wfile.write(b"Root path hit!") self.wfile.write(b"Root path hit!")
elif self.path == '/update_map': elif self.path == '/update_map':
# Send the response with a status code (e.g., 200 for success) markers_data, resp_code = get_markers()
self.send_response(200)
self.send_response(resp_code)
self.send_header("Content-type", "application/json") self.send_header("Content-type", "application/json")
self.end_headers() self.end_headers()
# Write the JSON data directly to the response # Write the JSON data directly to the response
markers_data = get_markers()
self.wfile.write(markers_data.encode('utf-8')) self.wfile.write(markers_data.encode('utf-8'))
elif self.path == '/test_endpoint': elif self.path == '/test_endpoint':
......
No preview for this file type
...@@ -6,13 +6,17 @@ sys.path.append(parent_dir) ...@@ -6,13 +6,17 @@ sys.path.append(parent_dir)
from data_structs import MarkerTemplate from data_structs import MarkerTemplate
from flask import json 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(): def get_markers():
testData = [ try:
MarkerTemplate(latitude=60.7266, longitude=10.9771, size=50.0, color='blue'), testData = [
MarkerTemplate(latitude=60.8366, longitude=10.8171, size=70.0, color='red'), MarkerTemplate(latitude=60.7266, longitude=10.9771, size=30.0, color='blue', radius=10.0),
MarkerTemplate(latitude=60.7366, longitude=10.8471, size=60.0, color='green'), 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 jsonified marker list
return json.dumps([marker.to_dict() for marker in testData]) 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