Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
|
3 |
+
# Sample data for demonstration
|
4 |
+
data = {
|
5 |
+
"topo_start_lat": [37.7749, 40.7128],
|
6 |
+
"topo_start_lon": [-122.4194, -74.0060],
|
7 |
+
"city": ["San Francisco", "New York"]
|
8 |
+
}
|
9 |
+
df = pd.DataFrame(data)
|
10 |
+
|
11 |
+
def select(data, event):
|
12 |
+
index = event.index[0]
|
13 |
+
row = df.iloc[index]
|
14 |
+
return Map(
|
15 |
+
location=[row['topo_start_lat'], row['topo_start_lon']],
|
16 |
+
zoom_start=10,
|
17 |
+
tiles="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
|
18 |
+
)
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown("# Explore World Capitals with Gradio and Folium")
|
22 |
+
map_component = Folium(value=Map(location=[0, 0], zoom_start=2))
|
23 |
+
data_table = gr.DataFrame(value=df)
|
24 |
+
data_table.select(select, inputs=data_table, outputs=map_component)
|
25 |
+
|
26 |
+
demo.launch()
|