7
7
from jinja2 import Template
8
8
9
9
from folium .map import Marker , Popup , Tooltip
10
- from folium .utilities import get_bounds , validate_locations
10
+ from folium .utilities import camelize , get_bounds , validate_locations
11
11
12
12
13
13
def path_options (line = False , radius = False , ** kwargs ):
@@ -59,21 +59,25 @@ def path_options(line=False, radius=False, **kwargs):
59
59
60
60
Note that the presence of `fill_color` will override `fill=False`.
61
61
62
+ This function accepts both snake_case and lowerCamelCase equivalents.
63
+
62
64
See https://leafletjs.com/reference.html#path
63
65
64
66
"""
65
67
68
+ kwargs = {camelize (key ): value for key , value in kwargs .items ()}
69
+
66
70
extra_options = {}
67
71
if line :
68
72
extra_options = {
69
- "smoothFactor" : kwargs .pop ("smooth_factor " , 1.0 ),
70
- "noClip" : kwargs .pop ("no_clip " , False ),
73
+ "smoothFactor" : kwargs .pop ("smoothFactor " , 1.0 ),
74
+ "noClip" : kwargs .pop ("noClip " , False ),
71
75
}
72
76
if radius :
73
77
extra_options .update ({"radius" : radius })
74
78
75
79
color = kwargs .pop ("color" , "#3388ff" )
76
- fill_color = kwargs .pop ("fill_color " , False )
80
+ fill_color = kwargs .pop ("fillColor " , False )
77
81
if fill_color :
78
82
fill = True
79
83
elif not fill_color :
@@ -89,15 +93,15 @@ def path_options(line=False, radius=False, **kwargs):
89
93
"color" : color ,
90
94
"weight" : kwargs .pop ("weight" , 3 ),
91
95
"opacity" : kwargs .pop ("opacity" , 1.0 ),
92
- "lineCap" : kwargs .pop ("line_cap " , "round" ),
93
- "lineJoin" : kwargs .pop ("line_join " , "round" ),
94
- "dashArray" : kwargs .pop ("dash_array " , None ),
95
- "dashOffset" : kwargs .pop ("dash_offset " , None ),
96
+ "lineCap" : kwargs .pop ("lineCap " , "round" ),
97
+ "lineJoin" : kwargs .pop ("lineJoin " , "round" ),
98
+ "dashArray" : kwargs .pop ("dashArray " , None ),
99
+ "dashOffset" : kwargs .pop ("dashOffset " , None ),
96
100
"fill" : fill ,
97
101
"fillColor" : fill_color ,
98
- "fillOpacity" : kwargs .pop ("fill_opacity " , 0.2 ),
99
- "fillRule" : kwargs .pop ("fill_rule " , "evenodd" ),
100
- "bubblingMouseEvents" : kwargs .pop ("bubbling_mouse_events " , True ),
102
+ "fillOpacity" : kwargs .pop ("fillOpacity " , 0.2 ),
103
+ "fillRule" : kwargs .pop ("fillRule " , "evenodd" ),
104
+ "bubblingMouseEvents" : kwargs .pop ("bubblingMouseEvents " , True ),
101
105
}
102
106
default .update (extra_options )
103
107
return default
0 commit comments