1717from branca .utilities import (_locations_tolist , _parse_size , image_to_url , iter_points , none_max , none_min ) # noqa
1818
1919from folium .map import FeatureGroup , Icon , Layer , Marker , Popup
20- from folium .utilities import _validate_coordinates , _validate_location
20+ from folium .utilities import _parse_path , _validate_coordinates , _validate_location
2121
2222from jinja2 import Template
2323
@@ -809,43 +809,37 @@ class Circle(Marker):
809809 location: tuple or list, default None
810810 Latitude and Longitude of Marker (Northing, Easting)
811811 radius: int
812- The radius of the circle in meters. For setting the radius in pixel,
813- use CircleMarker.
814- color: str, default 'black '
812+ The radius of the circle in meters.
813+ For setting the radius in pixel, use CircleMarker.
814+ color: str, default '#3388ff '
815815 The color of the marker's edge in a HTML-compatible format.
816- fill_color: str, default 'black'
816+ fill: bool, default False
817+ If true the circle will be filled.
818+ fill_color: str, default to the same as color
817819 The fill color of the marker in a HTML-compatible format.
818- fill_opacity: float, default 0.6
820+ fill_opacity: float, default 0.2
819821 The fill opacity of the marker, between 0. and 1.
820822 popup: string or folium.Popup, default None
821823 Input text or visualization for object.
822824
825+ See http://leafletjs.com/reference-1.2.0.html#path for more otions.
826+
823827 """
824- def __init__ (self , location , radius = 500 , color = 'black' ,
825- fill_color = 'black' , fill_opacity = 0.6 , popup = None ):
826- super (Circle , self ).__init__ (
827- _validate_location (location ),
828- popup = popup
829- )
830- self ._name = 'Circle'
831- self .radius = radius
832- self .color = color
833- self .fill_color = fill_color
834- self .fill_opacity = fill_opacity
828+ def __init__ (self , location , radius = 10 , popup = None , ** kw ):
829+ super (Circle , self ).__init__ (_validate_location (location ), popup = popup )
830+ self ._name = 'circle'
831+ options = _parse_path (** kw )
832+
833+ options .update ({'radius' : radius })
834+ self .options = json .dumps (options , sort_keys = True , indent = 2 )
835835
836836 self ._template = Template (u"""
837837 {% macro script(this, kwargs) %}
838838
839839 var {{this.get_name()}} = L.circle(
840840 [{{this.location[0]}},{{this.location[1]}}],
841- {{ this.radius }},
842- {
843- color: '{{ this.color }}',
844- fillColor: '{{ this.fill_color }}',
845- fillOpacity: {{ this.fill_opacity }}
846- }
847- )
848- .addTo({{this._parent.get_name()}});
841+ {{ this.options }}
842+ ).addTo({{this._parent.get_name()}});
849843 {% endmacro %}
850844 """ )
851845
@@ -859,45 +853,37 @@ class CircleMarker(Marker):
859853 location: tuple or list, default None
860854 Latitude and Longitude of Marker (Northing, Easting)
861855 radius: int
862- The radius of the circle in pixels. For setting the radius in meter,
863- use Circle.
864- color: str, default 'black '
856+ The radius of the circle in pixels.
857+ For setting the radius in meter, use Circle.
858+ color: str, default '#3388ff '
865859 The color of the marker's edge in a HTML-compatible format.
866- weight: int , default 2
867- Stroke weight in pixels
868- fill_color: str, default 'black'
860+ fill: bool , default False
861+ If true the circle will be filled.
862+ fill_color: str, default to the same as color
869863 The fill color of the marker in a HTML-compatible format.
870- fill_opacity: float, default 0.6
864+ fill_opacity: float, default 0.2
871865 The fill opacity of the marker, between 0. and 1.
872866 popup: string or folium.Popup, default None
873867 Input text or visualization for object.
874868
869+ See http://leafletjs.com/reference-1.2.0.html#path for more otions.
870+
875871 """
876- def __init__ (self , location , radius = 500 , color = 'black' ,
877- weight = 2 , fill_color = 'black' , fill_opacity = 0.6 ,
878- popup = None ):
879- super (CircleMarker , self ).__init__ (location , popup = popup )
872+ def __init__ (self , location , radius = 10 , popup = None , ** kw ):
873+ super (CircleMarker , self ).__init__ (_validate_location (location ), popup = popup )
880874 self ._name = 'CircleMarker'
881- self .radius = radius
882- self .color = color
883- self .weight = weight
884- self .fill_color = fill_color
885- self .fill_opacity = fill_opacity
875+ options = _parse_path (** kw )
876+
877+ options .update ({'radius' : radius })
878+ self .options = json .dumps (options , sort_keys = True , indent = 2 )
886879
887880 self ._template = Template (u"""
888881 {% macro script(this, kwargs) %}
889882
890883 var {{this.get_name()}} = L.circleMarker(
891884 [{{this.location[0]}},{{this.location[1]}}],
892- {
893- color: '{{ this.color }}',
894- weight: {{ this.weight }},
895- fillColor: '{{ this.fill_color }}',
896- fillOpacity: {{ this.fill_opacity }}
897- }
898- )
899- .setRadius({{ this.radius }})
900- .addTo({{this._parent.get_name()}});
885+ {{ this.options }}
886+ ).addTo({{this._parent.get_name()}});
901887 {% endmacro %}
902888 """ )
903889
0 commit comments