Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
|
4 |
def create_marker(bird):
|
5 |
species = bird['species']
|
@@ -9,13 +9,12 @@ def create_marker(bird):
|
|
9 |
end_month = bird['end_month']
|
10 |
popup_msg = f"{species}: {start_month} - {end_month}"
|
11 |
icon_text = f"{species} ({start_month} - {end_month})"
|
12 |
-
|
13 |
-
marker
|
14 |
-
marker.add_child(folium.Popup(icon_text))
|
15 |
return marker
|
16 |
|
17 |
def create_map(center, zoom, markers):
|
18 |
-
m =
|
19 |
for marker in markers:
|
20 |
marker.add_to(m)
|
21 |
return m
|
@@ -45,9 +44,10 @@ st.title("Bird Migration Map")
|
|
45 |
month = st.slider("Select a month", 1, 12, 1)
|
46 |
|
47 |
# Filter the markers by the selected month
|
48 |
-
selected_markers = [marker for marker in markers if month >= list(calendar.month_abbr).index(marker['start_month'][:3]) and month <= list(calendar.month_abbr).index
|
|
|
49 |
# Create the map with the filtered markers
|
50 |
m = create_map(center, zoom, selected_markers)
|
51 |
|
52 |
# Display the map on the Streamlit app
|
53 |
-
|
|
|
1 |
import streamlit as st
|
2 |
+
import leafmap.foliumap as leafmap
|
3 |
|
4 |
def create_marker(bird):
|
5 |
species = bird['species']
|
|
|
9 |
end_month = bird['end_month']
|
10 |
popup_msg = f"{species}: {start_month} - {end_month}"
|
11 |
icon_text = f"{species} ({start_month} - {end_month})"
|
12 |
+
marker = leafmap.Marker(location=[lat, lon], popup=popup_msg)
|
13 |
+
marker.add_child(leafmap.Popup(icon_text))
|
|
|
14 |
return marker
|
15 |
|
16 |
def create_map(center, zoom, markers):
|
17 |
+
m = leafmap.Map(center=center, zoom=zoom)
|
18 |
for marker in markers:
|
19 |
marker.add_to(m)
|
20 |
return m
|
|
|
44 |
month = st.slider("Select a month", 1, 12, 1)
|
45 |
|
46 |
# Filter the markers by the selected month
|
47 |
+
selected_markers = [marker for marker in markers if month >= list(calendar.month_abbr).index(marker['start_month'][:3]) and month <= list(calendar.month_abbr).index(marker['end_month'][:3])]
|
48 |
+
|
49 |
# Create the map with the filtered markers
|
50 |
m = create_map(center, zoom, selected_markers)
|
51 |
|
52 |
# Display the map on the Streamlit app
|
53 |
+
st.write(m)
|