I am new to python programming and Dash so please forgive me if I say something wrong. I am working with folium library and Dash. I have found this example on stackoverflow and I have converted folium map to an html document and passed that html doc into Dash (working with iframe component) and I have it displayed on my app.
Here is my code for displaying my app with Dash:
app = dash.Dash()
app.layout = html.Div([
html.H1('My first app with folium map'),
html.Iframe(id='map', srcDoc=open('example_map.html', 'r').read(), width='100%', height='600'),
html.Button(id='map-submit-button', n_clicks=0, children='Submit')
])
@app.callback(
dash.dependencies.Output('map', 'srcDoc'),
[dash.dependencies.Input('map-submit-button', 'n_clicks')])
def update_map(n_clicks):
if n_clicks is None:
return dash.no_update
else:
return html.Div([
html.H1('My first app with folium map'),
html.Iframe(id='map', srcDoc=open('example_map.html', 'r').read(), width='100%', height='600'),
html.Button(id='map-submit-button', n_clicks=0, children='Submit')
])
if __name__ == '__main__':
app.run_server(debug=True)
Now I am trying to refresh folium map (the html document that I have passed into Dash) using an app.callback in case the coords, from the html doc, are taken from a json API (which are being refreshed every 30sec), but it seems not working. Is this close to the proper way to do it? If not, how should I? Thank you in advance!!