@@ -662,6 +662,108 @@ def __init__(self, location, radius=500, color='black',
662662 """ )
663663
664664
665+ class RectangleMarker (Marker ):
666+ def __init__ (self , bounds , color = 'black' , weight = 1 , fill_color = 'black' ,
667+ fill_opacity = 0.6 , popup = None ):
668+ """Creates a RectangleMarker object for plotting on a Map.
669+
670+ Parameters
671+ ----------
672+ bounds: tuple or list, default None
673+ Latitude and Longitude of Marker (southWest and northEast)
674+ color: string, default ('black')
675+ Edge color of a rectangle.
676+ weight: float, default (1)
677+ Edge line width of a rectangle.
678+ fill_color: string, default ('black')
679+ Fill color of a rectangle.
680+ fill_opacity: float, default (0.6)
681+ Fill opacity of a rectangle.
682+ popup: string or folium.Popup, default None
683+ Input text or visualization for object.
684+
685+ Returns
686+ -------
687+ folium.features.RectangleMarker object
688+
689+ Example
690+ -------
691+ >>> RectangleMarker(bounds=[[35.681, 139.766], [35.691, 139.776]], color="blue", fill_color="red", popup='Tokyo, Japan')
692+ """
693+ super (RectangleMarker , self ).__init__ (bounds , popup = popup )
694+ self ._name = 'RectangleMarker'
695+ self .color = color
696+ self .weight = weight
697+ self .fill_color = fill_color
698+ self .fill_opacity = fill_opacity
699+ self ._template = Template (u"""
700+ {% macro script(this, kwargs) %}
701+ var {{this.get_name()}} = L.rectangle([[{{this.location[0]}}, {{this.location[1]}}],
702+ [{{this.location[2]}}, {{this.location[3]}}]],
703+ {
704+ color:'{{ this.color }}',
705+ fillColor:'{{ this.fill_color }}',
706+ fillOpacity:{{ this.fill_opacity }},
707+ weight:{{ this.weight }}
708+ }).addTo({{this._parent.get_name()}});
709+
710+ {% endmacro %}
711+ """ )
712+
713+
714+ class Polygon (Marker ):
715+ def __init__ (self , locations , color = 'black' , weight = 1 , fill_color = 'black' ,
716+ fill_opacity = 0.6 , popup = None , latlon = True ):
717+ """Creates a Polygon object for plotting on a Map.
718+
719+ Parameters
720+ ----------
721+ locations: tuple or list, default None
722+ Latitude and Longitude of Polygon
723+ color: string, default ('black')
724+ Edge color of a polygon.
725+ weight: float, default (1)
726+ Edge line width of a polygon.
727+ fill_color: string, default ('black')
728+ Fill color of a polygon.
729+ fill_opacity: float, default (0.6)
730+ Fill opacity of a polygon.
731+ popup: string or folium.Popup, default None
732+ Input text or visualization for object.
733+
734+ Returns
735+ -------
736+ folium.features.Polygon object
737+
738+ Example
739+ -------
740+ >>> loc= [[35.6762, 139.7795],
741+ [35.6718, 139.7831],
742+ [35.6767, 139.7868],
743+ [35.6795, 139.7824],
744+ [35.6787, 139.7791]]
745+ Polygon(loc, color="blue", weight=10, fill_color="red",
746+ fill_opacity=0.5, popup="Tokyo, Japan"))
747+ """
748+ super (Polygon , self ).__init__ ((_locations_mirror (locations ) if not latlon else
749+ _locations_tolist (locations )), popup = popup )
750+ self ._name = 'Polygon'
751+ self .color = color
752+ self .weight = weight
753+ self .fill_color = fill_color
754+ self .fill_opacity = fill_opacity
755+ self ._template = Template (u"""
756+ {% macro script(this, kwargs) %}
757+ var {{this.get_name()}} = L.polygon({{this.location}},
758+ {
759+ color: '{{ this.color }}',
760+ fillColor: '{{ this.fill_color }}',
761+ fillOpacity: {{ this.fill_opacity }},
762+ weight: {{ this.weight }}
763+ }).addTo({{this._parent.get_name()}});
764+ {% endmacro %}
765+ """ )
766+
665767class LatLngPopup (MacroElement ):
666768 """
667769 When one clicks on a Map that contains a LatLngPopup,
0 commit comments