From e6cffdd3d53d5d67fbab80f40202b0375290eaa9 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 14 Jan 2024 21:43:10 +0000 Subject: [PATCH] Show venue pins on the map Closes: #108 --- agenda/trip.py | 53 ++++++++++++++++++++++-------------------------- static/js/map.js | 1 + 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/agenda/trip.py b/agenda/trip.py index f7b5626..02c7775 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -104,38 +104,33 @@ def collect_trip_coordinates(trip: Trip) -> list[StrDict]: continue stations[s["uic"]] = s - accommodation_coordinates = [ - { - "name": accommodation["name"], - "type": "accommodation", - "latitude": accommodation["latitude"], - "longitude": accommodation["longitude"], - } - for accommodation in trip.accommodation - if "latitude" in accommodation and "longitude" in accommodation - ] + coords = [] - station_coordinates = [ - { - "name": s["name"], - "type": "station", - "latitude": s["latitude"], - "longitude": s["longitude"], - } - for s in stations.values() - ] + src = [("accommodation", trip.accommodation), ("conference", trip.conferences)] + for coord_type, item_list in src: + coords += [ + { + "name": item["name"], + "type": coord_type, + "latitude": item["latitude"], + "longitude": item["longitude"], + } + for item in item_list + if "latitude" in item and "longitude" in item + ] - airport_coordinates = [ - { - "name": s["name"], - "type": "airport", - "latitude": s["latitude"], - "longitude": s["longitude"], - } - for s in airports.values() - ] + for coord_type, coord_dict in ("station", stations), ("airport", airports): + coords += [ + { + "name": s["name"], + "type": coord_type, + "latitude": s["latitude"], + "longitude": s["longitude"], + } + for s in coord_dict.values() + ] - return accommodation_coordinates + station_coordinates + airport_coordinates + return coords def latlon_tuple(stop: StrDict) -> tuple[float, float]: diff --git a/static/js/map.js b/static/js/map.js index 302c831..c01d3c7 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -13,6 +13,7 @@ var icons = { "station": emoji_icon("🚉"), "airport": emoji_icon("✈️"), "accommodation": emoji_icon("🏨"), + "conference": emoji_icon("🎤"), } function build_map(map_id, coordinates, routes) {