Plotly Scattermapbox Figure - Draw Multiple Lines between points

Hello, I’m working on a Dash application that includes a Mapbox figure created using the plotly graph_objs module. The map includes a large number of markers connected by lines (essentially adding a mapbox layer displaying a network model where I can specify the nodes and edges using lat-long pairs). For efficient rendering, I use a callback function that reads the mapbox._derived property to only render nodes and edges within the window as the user manipulates the map viewport.

This method works great for the nodes, however drawing the edges between nodes is extremely slow. This is because the only way I’ve been able to add multiple lines is by looping through my edges dataframe and calling the ‘add_trace’ method on my figure for each line.

Is there a way to add multiple lines between two points to a Scattermapbox figure? I have seen the example at Lines on mapbox in Python, however this doesn’t work for me as I need to be able to specify the endpoints of each line, without calling add_trace for each line.