Spaces:
Sleeping
Sleeping
import streamlit as st | |
import folium | |
from streamlit_folium import folium_static | |
# Define mythological places data for Iceland | |
mythological_places = [ | |
('Ásbyrgi', 66.0082, -16.5096), | |
('Dimmuborgir', 65.6083, -16.8996), | |
('Hekla', 63.9920, -19.6656), | |
('Elliðaey', 63.4845, -20.2785), | |
('Mývatn', 65.6039, -16.9965), | |
('Djúpalónssandur', 64.7439, -23.9033), | |
('Reykjadalur', 64.0333, -21.2167), | |
('Snaefellsjokull', 64.8080, -23.7767), | |
('Jokulsarlon', 64.0784, -16.2300), | |
('Vatnajokull', 64.4150, -16.8333) | |
] | |
# Create a map centered on Iceland | |
m = folium.Map(location=[65.0, -18.0], zoom_start=7) | |
# Add markers for each mythological place | |
for place in mythological_places: | |
folium.Marker( | |
location=[place[1], place[2]], | |
popup=f'{place[0]}', | |
icon=folium.Icon(color='red') | |
).add_to(m) | |
# Function to update the map when a button is clicked | |
def update_map(place_data): | |
m.location = [place_data[1], place_data[2]] | |
m.zoom_start = 13 | |
folium_static(m) | |
# Create a grid of buttons for selecting mythological places | |
for i in range(0, len(mythological_places), 3): | |
cols = st.columns(3) | |
for j in range(3): | |
if i + j < len(mythological_places): | |
with cols[j]: | |
if st.button(mythological_places[i + j][0]): | |
update_map(mythological_places[i + j]) | |
# Display the map in Streamlit | |
folium_static(m) | |