Folium
Allows users to create interactive maps using the Folium library.
app.foliumchart
app.foliumchart(spec, title=None, on_change=None)
Parameters
Parameter | Description |
---|---|
spec (Any) | The JSON / HTML specification of the Folium map to be shown. |
title (str) | The title of the chart, shown above the Folium map. |
on_change (FoliumChartOnChange) | Event handler called when the map's data or state changes. |
Example
The basic example below shows how to create a Folium map widget.
from shapelets.apps import FoliumChart, dataApp
import folium
from typing import Any
# Set up Data App
app = dataApp()
# Set the title of the app
app.title('Folium Chart')
folium_Chart = folium.Map(location=[45.5236, -122.6750])
json_folium = folium_Chart._repr_html_()
# Define an event handler for interactive applications
def onChange(src: FoliumChart, value: Any):
print(f"type {value['type']} data {value['data']}")
# Add the FoliumChart --> app
app.foliumchart(
title="Folium Map Chart",
spec=json_folium,
on_change=onChange,
cssStyles={
"width": "100%",
"height": "600px",
},
)