Map of us
To upload files, please first save the app
import streamlit as st
import pandas as pd
import pydeck as pdk
# Load a dataset containing US state capitals
capitals = pd.read_csv(
"https://github.com/streamlit/docs/blob/main/python/api-examples-source/data/capitals.csv",
header=0,
names=["Capital", "State", "Abbreviation", "Latitude", "Longitude", "Population"]
)
# Create a scatterplot layer with US capitals
point_layer = pdk.Layer(
"ScatterplotLayer",
data=capitals,
get_position=["Longitude", "Latitude"],
get_color="[255, 75, 75]",
get_radius="Population / 10",
pickable=True,
)
# Set the view state for the map
view_state = pdk.ViewState(
longitude=-95.7129,
latitude=37.0902,
zoom=4,
pitch=0
)
# Create the pydeck Deck object
chart = pdk.Deck(
layers=[point_layer],
initial_view_state=view_state,
tooltip={"text": "{Capital}, {Abbreviation}\nPopulation: {Population}"},
)
# Render the map
st.pydeck_chart(chart)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?