我正在尝试将传单地图集成到我的 Dash 应用程序中,但在将其呈现为 HTML 时遇到问题。有人可以帮忙编写以下代码片段吗?
def update_map(n_clicks,input_value1,input_value2,marker_info =无): 如果 n_clicks > 0:
if input_value1 is None or input_value2 is None:
raise PreventUpdate
# Check if input values are not empty strings
if not input_value1.strip() or not input_value2.strip():
raise PreventUpdate
directions_json = get_directions(input_value1, input_value2)
route_line=convert_to_polyline(directions_json)
towers_near_highway= Geo_towers[Geo_towers.intersects(route_line)]
towers_near_highway = towers_near_highway[towers_near_highway['SITENAME'].str.len() == 6]
# Create a Folium map centered at a default location
mymap = Map(center=(36.8, 3), zoom=10, scroll_wheel_zoom=True)
polyline= Polyline(locations=route_line.coords[:], color="blue", fill_opacity=0)
mymap.add_layer(polyline)
# Convert the map to HTML
map_html = mymap._repr_html_()
# Return the HTML iframe element
return html.Iframe(srcDoc=map_html, style={"height": "500px", "width": "100%"})
else:
raise PreventUpdate
使用 dash-leaflet 怎么样?