diff --git a/osmnx/folium.py b/osmnx/folium.py
index <HASH>..<HASH> 100644
--- a/osmnx/folium.py
+++ b/osmnx/folium.py
@@ -92,7 +92,7 @@ def plot_route_folium(
     """
     # create gdf of the route edges in order
     node_pairs = zip(route[:-1], route[1:])
-    uvk = ((u, v, min(G[u][v], key=lambda k: G[u][v][k]["length"])) for u, v in node_pairs)
+    uvk = ((u, v, min(G[u][v].items(), key=lambda k: k[1]["length"])[0]) for u, v in node_pairs)
     gdf_edges = utils_graph.graph_to_gdfs(G.subgraph(route), nodes=False).loc[uvk]
     return _plot_folium(gdf_edges, route_map, popup_attribute, tiles, zoom, fit_bounds, **kwargs)
Fix late binding

flake8-bugbear complains of "B<I> Function definition does not bind loop
variable 'u'."

This is not really a bug, because the lambda only lasts as long as a
single iteration of the iterator. Fix the warning by passing the graph
as a parameter to the key lambda, which avoids binding the loop var.