Show accommodation pins on the map

This commit is contained in:
Edward Betts 2024-01-14 21:00:19 +00:00
parent f60a1a329c
commit 7ca5eafd1d

View file

@ -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);
});