awacke1's picture
Update app.py
72f9bed
raw
history blame
1.95 kB
import folium
def create_marker(bird):
species = bird['species']
lat = bird['lat']
lon = bird['lon']
start_month = bird['start_month']
end_month = bird['end_month']
popup_msg = f"{species}: {start_month} - {end_month}"
icon_text = f"{species} ({start_month} - {end_month})"
icon = folium.Icon(color='red', icon='glyphicon-map-marker', prefix='glyphicon')
marker = folium.Marker(location=[lat, lon], popup=popup_msg)
marker.add_child(folium.Popup(icon_text))
return marker
def create_map(center, zoom, markers):
m = folium.Map(location=center, zoom_start=zoom)
for marker in markers:
marker.add_to(m)
return m
birds = [
{'species': 'Canada Goose', 'lat': 44.9778, 'lon': -93.2650, 'start_month': 'September', 'end_month': 'April'},
{'species': 'Mallard Duck', 'lat': 44.8835, 'lon': -93.2273, 'start_month': 'August', 'end_month': 'May'},
{'species': 'Wood Duck', 'lat': 44.9778, 'lon': -93.2650, 'start_month': 'March', 'end_month': 'November'},
{'species': 'Trumpeter Swan', 'lat': 45.0941, 'lon': -94.2392, 'start_month': 'October', 'end_month': 'April'},
{'species': 'Tundra Swan', 'lat': 44.9358, 'lon': -93.1553, 'start_month': 'November', 'end_month': 'April'},
{'species': 'Canvasback', 'lat': 44.8835, 'lon': -93.2273, 'start_month': 'September', 'end_month': 'May'},
{'species': 'Redhead', 'lat': 44.9778, 'lon': -93.2650, 'start_month': 'September', 'end_month': 'May'},
{'species': 'Greater Scaup', 'lat': 44.8835, 'lon': -93.2273, 'start_month': 'September', 'end_month': 'May'},
{'species': 'Lesser Scaup', 'lat': 44.9778, 'lon': -93.2650, 'start_month': 'September', 'end_month': 'May'},
{'species': 'Hooded Merganser', 'lat': 44.8835, 'lon': -93.2273, 'start_month': 'October', 'end_month': 'April'}
]
markers = [create_marker(bird) for bird in birds]
center = [44.9778, -93.2650]
zoom = 8
create_map(center, zoom, markers)