@@ -340,22 +340,25 @@ def create_map(
340340 Plots the given routes on a folium map.
341341 """
342342 # Determine bbox
343- bbox = common .bounding_box ([r .points for r in routes ])
343+ bbox = common .bounding_box ([r .points for r in routes ] + unassigned )
344344
345345 # Make map plot of routes
346- m = common .create_map (
346+ m , base_tree = common .create_map (
347347 (bbox .max_x + bbox .min_x ) / 2.0 ,
348348 (bbox .max_y + bbox .min_y ) / 2.0 ,
349349 custom_map_tile ,
350350 )
351351 route_groups = {}
352+ route_layer_names = {}
352353 unassigned_group = folium .FeatureGroup ("Unassigned" )
353354
354355 # Plot the routes themselves
355356 for i , route in enumerate (routes ):
356357 if len (route .points ) <= 0 :
357358 continue
358- route_groups [route ] = folium .FeatureGroup (f"Route { i + 1 } " )
359+ layer_name = f"Route { i + 1 } "
360+ route_groups [route ] = folium .FeatureGroup (layer_name )
361+ route_layer_names [route_groups [route ]] = layer_name
359362 plot_map_route (
360363 route_groups [route ],
361364 route ,
@@ -450,8 +453,36 @@ def create_map(
450453 if len (unassigned ) > 0 :
451454 unassigned_group .add_to (m )
452455
456+ # Add button to expand the map to fullscreen
457+ plugins .Fullscreen (
458+ position = "topright" ,
459+ title = "Expand me" ,
460+ title_cancel = "Exit me" ,
461+ ).add_to (m )
462+
463+ # Create overlay tree for advanced control of route/unassigned layers
464+ overlay_tree = {
465+ "label" : "Overlays" ,
466+ "select_all_checkbox" : "Un/select all" ,
467+ "children" : [],
468+ }
469+ if len (unassigned ) > 0 :
470+ overlay_tree ["children" ].append ({"label" : "Unassigned" , "layer" : unassigned_group })
471+ if len (route_groups ) > 0 :
472+ overlay_tree ["children" ].append (
473+ {
474+ "label" : "Routes" ,
475+ "select_all_checkbox" : True ,
476+ "collapsed" : True ,
477+ "children" : [{"label" : route_layer_names [v ], "layer" : v } for v in route_groups .values ()],
478+ },
479+ )
480+
453481 # Add control for all layers and write file
454- folium .LayerControl ().add_to (m )
482+ plugins .TreeLayerControl (base_tree = base_tree , overlay_tree = overlay_tree ).add_to (m )
483+
484+ # Fit map to bounds
485+ m .fit_bounds ([[bbox .min_y , bbox .min_x ], [bbox .max_y , bbox .max_x ]])
455486
456487 # Return map
457488 return m
@@ -658,7 +689,7 @@ def nextroute_profile() -> RoutePlotProfile:
658689 jpath_route = "solutions[-1].vehicles[*].route" ,
659690 jpath_x = "stop.location.lon" ,
660691 jpath_y = "stop.location.lat" ,
661- jpath_unassigned = "solutions[-1].unplanned" ,
692+ jpath_unassigned = "solutions[-1].unplanned[*] " ,
662693 jpath_unassigned_x = "location.lon" ,
663694 jpath_unassigned_y = "location.lat" ,
664695 )
@@ -746,7 +777,7 @@ def plot_map_route(
746777 polyline .add_to (map )
747778 plugins .PolyLineTextPath (
748779 polyline ,
749- "\u25BA " ,
780+ "\u25ba " ,
750781 repeat = True ,
751782 center = True ,
752783 offset = 10.35 * weight ,
0 commit comments