interactive map
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
st.title("Interactive Map")
# Generate random data points around San Francisco
samples = 1000
df = pd.DataFrame(
np.random.randn(samples, 2) / [50, 50] + [37.76, -122.4],
columns=['lat', 'lon']
)
# Add random size and color values
df['size'] = np.random.randint(50, 500, samples)
df['color'] = [
[r/255, g/255, b/255]
for r, g, b in np.random.randint(0, 255, (samples, 3))
]
# Controls
st.sidebar.header("Map Controls")
show_size = st.sidebar.checkbox("Dynamic point sizes", value=True)
show_color = st.sidebar.checkbox("Dynamic colors", value=True)
base_size = st.sidebar.slider("Base point size", 50, 300, 100)
# Display map
st.write("### Points of Interest in San Francisco")
st.map(
data=df,
size='size' if show_size else base_size,
color='color' if show_color else [1, 0, 0],
zoom=11
)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?