File size: 977 Bytes
e1c04ec
 
 
f4da9b4
 
5807294
 
 
ab1c60c
34479d1
f4da9b4
 
 
 
 
 
 
 
 
 
 
 
 
 
eaf26d2
f4da9b4
 
 
 
 
 
 
 
1502776
 
b975533
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from gradio_folium import Folium
from folium import Map, TileLayer
import pandas as pd

from importlib.metadata import version
print(version('folium'))
print(version('gradio_folium'))
print(version('gradio'))
print(version('python'))
# Sample data for demonstration
data = {
    "topo_start_lat": [37.7749, 40.7128],
    "topo_start_lon": [-122.4194, -74.0060],
    "city": ["San Francisco", "New York"]
}
df = pd.DataFrame(data)

def select(data, event):
    index = event.index[0]
    row = df.iloc[index]
    return Map(
        location=[row['topo_start_lat'], row['topo_start_lon']],
        zoom_start=10,
  
    )

with gr.Blocks() as demo:
    gr.Markdown("# Explore World Capitals with Gradio and Folium")
    map_component = Folium(value=Map(location=[0, 0], zoom_start=2))
    data_table = gr.DataFrame(value=df)
    data_table.select(select, inputs=data_table, outputs=map_component)


if __name__ == "__main__":
    demo.launch(ssr_mode=False)