Spaces:
Sleeping
Sleeping
import streamlit as st | |
import folium | |
from streamlit_folium import folium_static | |
from folium.plugins import MarkerCluster | |
# Define California attractions data | |
california_attractions = [ | |
('The Getty Center', 34.0780, -118.4741, 'The Getty Center is known for its architecture, gardens, and views overlooking Los Angeles.'), | |
('Venice Beach', 33.9850, -118.4695, 'Venice Beach is famous for its oceanfront boardwalk and Muscle Beach gym.'), | |
('Santa Monica Pier', 34.0104, -118.4962, 'Santa Monica Pier features a range of entertainment, dining, and shopping experiences.'), | |
('Golden Gate Bridge', 37.8199, -122.4783, 'The Golden Gate Bridge is a suspension bridge spanning the Golden Gate, the entrance to San Francisco Bay.'), | |
('Yosemite National Park', 37.8651, -119.5383, 'Known for its waterfalls, deep valleys, and iconic view of El Capitan.'), | |
('Disneyland', 33.8121, -117.9190, 'Disneyland Resort, located in Anaheim, is the first of two theme parks built under the Disneyland umbrella.'), | |
('Napa Valley', 38.5025, -122.2654, 'Napa Valley is known for its world-class wineries.'), | |
('Lake Tahoe', 39.0968, -120.0324, 'Lake Tahoe is a large freshwater lake known for its clear blue water.'), | |
('Universal Studios', 34.1381, -118.3534, 'Universal Studios Hollywood includes a movie-based theme park and studios that offers tours.'), | |
('Alcatraz Island', 37.8267, -122.4230, 'Alcatraz Island is home to the abandoned prison and the site of the oldest operating lighthouse.') | |
] | |
# Create a map centered on California | |
m = folium.Map(location=[36.7783, -119.4179], zoom_start=6) | |
# Add markers for each attraction and add them to a MarkerCluster | |
marker_cluster = MarkerCluster().add_to(m) | |
for place in california_attractions: | |
folium.Marker( | |
location=[place[1], place[2]], | |
popup=f'<b>{place[0]}</b><br>{place[3]}', | |
icon=folium.Icon(color='green') | |
).add_to(marker_cluster) | |
# Add PolyLine for paths between markers with animation | |
locations = [place[1:3] for place in california_attractions] | |
path = folium.PolyLine(locations, color='blue', opacity=0.8, weight=5, smooth_factor=0.5).add_to(m) | |
folium.plugins.PolyLineTextPath( | |
polyline=path, | |
text='\u25BA', | |
repeat=True, | |
offset=6, | |
attributes={'fill': 'blue', 'font-weight': 'bold', 'font-size': '12'} | |
).add_to(path) | |
folium_static(m) | |
st.markdown(""" | |
# π California Attractions π΄ | |
The map above shows the location of various attractions in California. Hover over the markers to learn more about each location. | |
""") | |
# 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) | |
for i in range(0, len(california_attractions), 3): | |
cols = st.columns(3) | |
for j in range(3): | |
if i + j < len(california_attractions): | |
with cols[j]: | |
if st.button(california_attractions[i + j][0]): | |
update_map(california_attractions[i + j]) | |
folium_static(m) | |
st.markdown(""" | |
## π· Napa Valley: The Wine Wonderland π | |
Napa Valley, located in the heart of California, is synonymous with premium wines, fine dining, and breathtaking vistas. Not only is it a world-class wine-producing region, but it's also a paradise for foodies and outdoor enthusiasts. π₯ | |
Whether you're a sommelier or a casual wine drinker, Napa Valley offers a wide range of experiences, from vineyard tours and wine-tasting sessions to hot air balloon rides over the scenic countryside. π | |
The valley is home to over 400 wineries, each with its own unique blend of grape varieties, production techniques, and flavors. πΎ | |
""") | |