@@ -725,6 +725,110 @@ def __init__(self, location, radius=500, color='black',
725725 """ )
726726
727727
728+ class RectangleMarker (Marker ):
729+ def __init__ (self , bounds , color = 'black' , weight = 1 , fill_color = 'black' ,
730+ fill_opacity = 0.6 , popup = None ):
731+ """Creates a RectangleMarker object for plotting on a Map.
732+
733+ Parameters
734+ ----------
735+ bounds: tuple or list, default None
736+ Latitude and Longitude of Marker (southWest and northEast)
737+ color: string, default ('black')
738+ Edge color of a rectangle.
739+ weight: float, default (1)
740+ Edge line width of a rectangle.
741+ fill_color: string, default ('black')
742+ Fill color of a rectangle.
743+ fill_opacity: float, default (0.6)
744+ Fill opacity of a rectangle.
745+ popup: string or folium.Popup, default None
746+ Input text or visualization for object.
747+
748+ Returns
749+ -------
750+ folium.features.RectangleMarker object
751+
752+ Example
753+ -------
754+ >>> RectangleMarker(bounds=[[35.681, 139.766], [35.691, 139.776]],
755+ color="blue", fill_color="red", popup='Tokyo, Japan')
756+ """
757+ super (RectangleMarker , self ).__init__ (bounds , popup = popup )
758+ self ._name = 'RectangleMarker'
759+ self .color = color
760+ self .weight = weight
761+ self .fill_color = fill_color
762+ self .fill_opacity = fill_opacity
763+ self ._template = Template (u"""
764+ {% macro script(this, kwargs) %}
765+ var {{this.get_name()}} = L.rectangle([[{{this.location[0]}}, {{this.location[1]}}],
766+ [{{this.location[2]}}, {{this.location[3]}}]],
767+ {
768+ color:'{{ this.color }}',
769+ fillColor:'{{ this.fill_color }}',
770+ fillOpacity:{{ this.fill_opacity }},
771+ weight:{{ this.weight }}
772+ }).addTo({{this._parent.get_name()}});
773+
774+ {% endmacro %}
775+ """ )
776+
777+
778+ class Polygon (Marker ):
779+ def __init__ (self , locations , color = 'black' , weight = 1 , fill_color = 'black' ,
780+ fill_opacity = 0.6 , popup = None , latlon = True ):
781+ """Creates a Polygon object for plotting on a Map.
782+
783+ Parameters
784+ ----------
785+ locations: tuple or list, default None
786+ Latitude and Longitude of Polygon
787+ color: string, default ('black')
788+ Edge color of a polygon.
789+ weight: float, default (1)
790+ Edge line width of a polygon.
791+ fill_color: string, default ('black')
792+ Fill color of a polygon.
793+ fill_opacity: float, default (0.6)
794+ Fill opacity of a polygon.
795+ popup: string or folium.Popup, default None
796+ Input text or visualization for object.
797+
798+ Returns
799+ -------
800+ folium.features.Polygon object
801+
802+ Example
803+ -------
804+ >>> loc= [[35.6762, 139.7795],
805+ [35.6718, 139.7831],
806+ [35.6767, 139.7868],
807+ [35.6795, 139.7824],
808+ [35.6787, 139.7791]]
809+ Polygon(loc, color="blue", weight=10, fill_color="red",
810+ fill_opacity=0.5, popup="Tokyo, Japan"))
811+ """
812+ super (Polygon , self ).__init__ ((_locations_mirror (locations ) if not latlon else
813+ _locations_tolist (locations )), popup = popup )
814+ self ._name = 'Polygon'
815+ self .color = color
816+ self .weight = weight
817+ self .fill_color = fill_color
818+ self .fill_opacity = fill_opacity
819+ self ._template = Template (u"""
820+ {% macro script(this, kwargs) %}
821+ var {{this.get_name()}} = L.polygon({{this.location}},
822+ {
823+ color: '{{ this.color }}',
824+ fillColor: '{{ this.fill_color }}',
825+ fillOpacity: {{ this.fill_opacity }},
826+ weight: {{ this.weight }}
827+ }).addTo({{this._parent.get_name()}});
828+ {% endmacro %}
829+ """ )
830+
831+
728832class LatLngPopup (MacroElement ):
729833 """
730834 When one clicks on a Map that contains a LatLngPopup,
0 commit comments