diff --git a/app/assets/icons/marker.png b/app/assets/icons/marker.png new file mode 100644 index 0000000000000000000000000000000000000000..c9d6980c6ba0227597af40e6235257800076f17e Binary files /dev/null and b/app/assets/icons/marker.png differ diff --git a/app/lib/main.dart b/app/lib/main.dart index 8fde36353a78abc516b1c8ff4b5eb24a8620ea62..e06dfabcd90b8de6c3cfa5adc35dfe1bda7ba0f5 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -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, + ), + ], + ),*/ ], ), ), diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 7d385a53bf526fef8a336ccb16d1bc9e5726088b..35f346897616228a5c3b33ccbc4b5fc1f3a11d4b 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -22,3 +22,6 @@ dev_dependencies: flutter: uses-material-design: true + assets: + - assets/icons/marker.png + diff --git a/server/__pycache__/data_structs.cpython-311.pyc b/server/__pycache__/data_structs.cpython-311.pyc index 7ee79c1976488f599402e6e459d3e6d73df7af1c..397569683b62a9073b0e3b720effd2f1eaba34ab 100644 Binary files a/server/__pycache__/data_structs.cpython-311.pyc and b/server/__pycache__/data_structs.cpython-311.pyc differ diff --git a/server/data_structs.py b/server/data_structs.py index 6e289e54101abe911d73f9c6175ba2f1ea87ef0b..0b0ef26309f879e0bd4c7fe085cba736ec1509ea 100644 --- a/server/data_structs.py +++ b/server/data_structs.py @@ -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 diff --git a/server/main.py b/server/main.py index 97253949bb348a70b72262b5eb0e1c6a663edd7c..6821170123cc7ab68ae6cfcc01acd9df8680eddd 100644 --- a/server/main.py +++ b/server/main.py @@ -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': diff --git a/server/map/__pycache__/get_markers.cpython-311.pyc b/server/map/__pycache__/get_markers.cpython-311.pyc index 584c67ac6dd58b5d3fbcc9f35fa30569e4a48c80..f04859b983ec11f6515debfd00844265d08e9894 100644 Binary files a/server/map/__pycache__/get_markers.cpython-311.pyc and b/server/map/__pycache__/get_markers.cpython-311.pyc differ diff --git a/server/map/get_markers.py b/server/map/get_markers.py index f59ca2b4941c28df79d0450d713596da3c95e208..e1c14a488d327e5be73df0301868a59508ba7fe2 100644 --- a/server/map/get_markers.py +++ b/server/map/get_markers.py @@ -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