@@ -382,6 +382,58 @@ def line(self, locations,
382382 add_line ))
383383
384384
385+ @iter_obj ('multiline' )
386+ def multiline (self , locations ,
387+ line_color = None , line_opacity = None , line_weight = None ):
388+ '''Add a multiPolyline to the map with optional styles.
389+
390+ A multiPolyline is single layer that consists of several polylines that
391+ share styling/popup.
392+
393+ Parameters
394+ ----------
395+ locations: list of lists of points (latitude, longitude)
396+ Latitude and Longitude of line (Northing, Easting)
397+ line_color: string, default Leaflet's default ('#03f')
398+ line_opacity: float, default Leaflet's default (0.5)
399+ line_weight: float, default Leaflet's default (5)
400+
401+ Note: If the optional styles are omitted, they will not be included
402+ in the HTML output and will obtain the Leaflet defaults listed above.
403+
404+ Example
405+ -------
406+ >>>map.multiline(locations=[[(45.5236, -122.6750), (45.5236, -122.6751)],
407+ [(45.5237, -122.6750), (45.5237, -122.6751)],
408+ [(45.5238, -122.6750), (45.5238, -122.6751)]])
409+ >>>map.multiline(locations=[[(45.5236, -122.6750), (45.5236, -122.6751)],
410+ [(45.5237, -122.6750), (45.5237, -122.6751)],
411+ [(45.5238, -122.6750), (45.5238, -122.6751)]],
412+ line_color='red',
413+ line_weight=2,
414+ line_opacity=1.0)
415+ '''
416+
417+ count = self .mark_cnt ['multiline' ]
418+
419+ multiline_temp = self .env .get_template ('multi_polyline.js' )
420+
421+ multiline_opts = {'color' : line_color ,
422+ 'weight' : line_weight ,
423+ 'opacity' : line_opacity }
424+
425+ varname = 'multiline_{}' .format (count )
426+ multiline_rendered = multiline_temp .render ({'multiline' : varname ,
427+ 'locations' : locations ,
428+ 'options' : multiline_opts })
429+
430+ add_multiline = 'map.addLayer({});' .format (varname )
431+
432+ self .template_vars .setdefault ('multilines' , []).append ((multiline_rendered ,
433+ add_multiline ))
434+
435+
436+
385437 @iter_obj ('circle' )
386438 def circle_marker (self , location = None , radius = 500 , popup = 'Pop Text' ,
387439 popup_on = True , line_color = 'black' , fill_color = 'black' ,
0 commit comments