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

add: make markers interactive

parent 373511e1
No related branches found
No related tags found
1 merge request!1Server
app/assets/icons/marker.png

4.7 KiB

......@@ -151,22 +151,29 @@ 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.location_on,
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: markerData.size,
),
),
),
)
.toList(),
);
}).toList(),
),
],
),
),
......
......@@ -22,3 +22,6 @@ dev_dependencies:
flutter:
uses-material-design: true
assets:
- assets/icons/marker.png
......@@ -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,19 @@ sys.path.append(parent_dir)
from data_structs import MarkerTemplate
from flask import json
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])
# 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():
try:
testData = [
MarkerTemplate(latitude=60.7266, longitude=10.9771, size=30.0, color='blue'),
MarkerTemplate(latitude=60.8366, longitude=10.8171, size=20.0, color='red'),
MarkerTemplate(latitude=60.7366, longitude=10.8471, size=10.0, color='green'),
]
return json.dumps([marker.to_dict() for marker in testData]), 200
except Exception as e:
return e, 500
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