From 7ca5eafd1d9a09228a380a3dfb91746ab34db590 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 14 Jan 2024 21:00:19 +0000 Subject: [PATCH] Show accommodation pins on the map --- static/js/map.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/static/js/map.js b/static/js/map.js index cbf186b..d55694a 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -6,8 +6,11 @@ function emoji_icon(emoji) { }); } -var stationIcon = emoji_icon("🚉"); -var airportIcon = emoji_icon("✈️"); +var icons = { + "station": emoji_icon("🚉"), + "airport": emoji_icon("✈️"), + "accommodation": emoji_icon("🏨"), +} function build_map(map_id, coordinates, routes) { // Initialize the map @@ -22,8 +25,7 @@ function build_map(map_id, coordinates, routes) { // Add markers with appropriate icons to the map coordinates.forEach(function(item) { - var icon = item.type === "station" ? stationIcon : airportIcon; - var marker = L.marker([item.latitude, item.longitude], { icon: icon }).addTo(map); + var marker = L.marker([item.latitude, item.longitude], { icon: icons[item.type] }).addTo(map); marker.bindPopup(item.name); });