99import json
1010
1111from .utilities import (color_brewer , _parse_size , legend_scaler ,
12- _locations_mirror , _locations_tolist , image_to_url )
12+ _locations_mirror , _locations_tolist , image_to_url ,
13+ text_type , binary_type )
1314
1415from .element import Element , Figure , JavascriptLink , CssLink , MacroElement
15- from .map import TileLayer , Icon , Marker
16+ from .map import TileLayer , Icon , Marker , Popup
1617
1718
1819class WmsTileLayer (TileLayer ):
@@ -502,7 +503,7 @@ def __init__(self, popup=None):
502503
503504class PolyLine (MacroElement ):
504505 def __init__ (self , locations , color = None , weight = None ,
505- opacity = None , latlon = True ):
506+ opacity = None , latlon = True , popup = None ):
506507 """
507508 Creates a PolyLine object to append into a map with
508509 Map.add_children.
@@ -519,6 +520,8 @@ def __init__(self, locations, color=None, weight=None,
519520 or not ([[lon, lat]] if False).
520521 Note that the default GeoJson format is latlon=False,
521522 while Leaflet polyline's default is latlon=True.
523+ popup: string or folium.Popup, default None
524+ Input text or visualization for object.
522525 """
523526 super (PolyLine , self ).__init__ ()
524527 self ._name = 'PolyLine'
@@ -527,6 +530,10 @@ def __init__(self, locations, color=None, weight=None,
527530 self .color = color
528531 self .weight = weight
529532 self .opacity = opacity
533+ if isinstance (popup , text_type ) or isinstance (popup , binary_type ):
534+ self .add_children (Popup (popup ))
535+ elif popup is not None :
536+ self .add_children (popup )
530537
531538 self ._template = Template (u"""
532539 {% macro script(this, kwargs) %}
@@ -544,7 +551,7 @@ def __init__(self, locations, color=None, weight=None,
544551
545552class MultiPolyLine (MacroElement ):
546553 def __init__ (self , locations , color = None , weight = None ,
547- opacity = None , latlon = True ):
554+ opacity = None , latlon = True , popup = None ):
548555 """
549556 Creates a MultiPolyLine object to append into a map with
550557 Map.add_children.
@@ -561,6 +568,8 @@ def __init__(self, locations, color=None, weight=None,
561568 or not ([[lon, lat]] if False).
562569 Note that the default GeoJson format is latlon=False,
563570 while Leaflet polyline's default is latlon=True.
571+ popup: string or folium.Popup, default None
572+ Input text or visualization for object.
564573 """
565574 super (MultiPolyLine , self ).__init__ ()
566575 self ._name = 'MultiPolyLine'
@@ -569,6 +578,10 @@ def __init__(self, locations, color=None, weight=None,
569578 self .color = color
570579 self .weight = weight
571580 self .opacity = opacity
581+ if isinstance (popup , text_type ) or isinstance (popup , binary_type ):
582+ self .add_children (Popup (popup ))
583+ elif popup is not None :
584+ self .add_children (popup )
572585
573586 self ._template = Template (u"""
574587 {% macro script(this, kwargs) %}
0 commit comments