Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,25 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import folium
|
| 4 |
+
|
| 5 |
+
# Set title of the app
|
| 6 |
+
st.title('Streamlit with Leaflet')
|
| 7 |
+
|
| 8 |
+
# Create a sample dataframe
|
| 9 |
+
data = pd.DataFrame({
|
| 10 |
+
'lat': [37.7749, 34.0522, 40.7128],
|
| 11 |
+
'lon': [-122.4194, -118.2437, -74.0060],
|
| 12 |
+
'name': ['San Francisco', 'Los Angeles', 'New York']
|
| 13 |
+
})
|
| 14 |
+
|
| 15 |
+
# Display a header
|
| 16 |
+
st.subheader('Map of Cities')
|
| 17 |
+
|
| 18 |
+
# Display the map using Folium
|
| 19 |
+
my_map = folium.Map(location=[data['lat'].mean(), data['lon'].mean()], zoom_start=4)
|
| 20 |
+
|
| 21 |
+
for i, row in data.iterrows():
|
| 22 |
+
folium.Marker([row['lat'], row['lon']], popup=row['name']).add_to(my_map)
|
| 23 |
+
|
| 24 |
+
# Render the map in Streamlit
|
| 25 |
+
folium_static(my_map)
|