awacke1 commited on
Commit
94c7e11
·
1 Parent(s): 87f89f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- import folium
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
- icon = folium.Icon(color='red', icon='glyphicon-map-marker', prefix='glyphicon')
13
- marker = folium.Marker(location=[lat, lon], popup=popup_msg)
14
- marker.add_child(folium.Popup(icon_text))
15
  return marker
16
 
17
  def create_map(center, zoom, markers):
18
- m = folium.Map(location=center, zoom_start=zoom)
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
- folium_static(m)
 
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)