✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Dash and Folium integration

Hello to the whole community,

First of all manythanks for this wonderful Dash Product that’s look very smart .
I would like to know if there is a way to interact from Dash with a map produced by folium (via a frame, or any other html component).

Thanks for your help


I’m unfamiliar with folium, but in order to tie interactivity from a folium graph back into the dash app, someone would need to make a folium dash component which would render leaflet.js maps based off of however folium serializes its data within a react component. Here are the docs on the plugin system: https://plot.ly/dash/plugins.

Note that the dcc.Graph component also has built-in support for maps including:

With the dcc.Graph component, you can tie hover, select, and click interactions back to your dash code:

Here’s the sample code for that last example:

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

import json
import pandas as pd
df = pd.read_csv(
    'https://raw.githubusercontent.com/plotly' +

app = dash.Dash()

app.layout = html.Div([
        html.Pre(id='lasso', style={'overflowY': 'scroll', 'height': '100vh'}),
        className="three columns"

        className="nine columns",
                'data': [{
                    'lat': df.lat, 'lon': df.long, 'type': 'scattermapbox'
                'layout': {
                    'mapbox': {
                        'accesstoken': (
                            'pk.eyJ1IjoiY2hyaWRkeXAiLCJhIjoiY2ozcGI1MTZ3M' +
                    'margin': {
                        'l': 0, 'r': 0, 'b': 0, 't': 0
], className="row")

    'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'

    Output('lasso', 'children'),
    [Input('graph', 'selectedData')])
def display_data(selectedData):
    return json.dumps(selectedData, indent=2)

if __name__ == '__main__':

I would like to thank yo very much for your response @chriddyp . In fact your response may be clear for an expert of Dash library., which is not my case. I will probably never be able to design my own plugin for “folium” …
But thanks for giviing me a rasponse … It has been really appreciated.

Have a nice evening