Skip to content

Commit f61b738

Browse files
authored
Merge pull request #581 from california-civic-data-coalition/weight-circle-marker
Added weight option to CircleMarker
2 parents a2b227a + b288b4d commit f61b738

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

folium/features.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ class CircleMarker(Marker):
753753
use Circle.
754754
color: str, default 'black'
755755
The color of the marker's edge in a HTML-compatible format.
756+
weight: int, default 2
757+
Stroke weight in pixels
756758
fill_color: str, default 'black'
757759
The fill color of the marker in a HTML-compatible format.
758760
fill_opacity: float, default 0.6
@@ -762,11 +764,13 @@ class CircleMarker(Marker):
762764
763765
"""
764766
def __init__(self, location, radius=500, color='black',
765-
fill_color='black', fill_opacity=0.6, popup=None):
767+
weight=2, fill_color='black', fill_opacity=0.6,
768+
popup=None):
766769
super(CircleMarker, self).__init__(location, popup=popup)
767770
self._name = 'CircleMarker'
768771
self.radius = radius
769772
self.color = color
773+
self.weight = weight
770774
self.fill_color = fill_color
771775
self.fill_opacity = fill_opacity
772776

@@ -777,6 +781,7 @@ def __init__(self, location, radius=500, color='black',
777781
[{{this.location[0]}},{{this.location[1]}}],
778782
{
779783
color: '{{ this.color }}',
784+
weight: {{ this.weight }},
780785
fillColor: '{{ this.fill_color }}',
781786
fillOpacity: {{ this.fill_opacity }}
782787
}

folium/templates/circle_marker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var {{ circle }} = L.circleMarker([{{ lat }}, {{ lon }}], {
22
color: '{{ line_color }}',
3+
weight: {{ weight }},
34
fillColor: '{{ fill_color }}',
45
fillOpacity: {{ fill_opacity }}
5-
}).setRadius({{ radius }})
6+
}).setRadius({{ radius }})

tests/test_features.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def test_marker_popups():
7272
features.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
7373
features.CircleMarker([45, 60], popup='60').add_to(m)
7474
features.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
75+
features.CircleMarker([45, 90], popup=Popup('90'), weight=0).add_to(m)
7576
m._repr_html_()
7677

7778
bounds = m.get_bounds()

tests/test_folium.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,20 @@ def test_circle_marker(self):
169169
circle_1 = circ_templ.render({'circle': marker.get_name(),
170170
'lat': 45.60,
171171
'lon': -122.8, 'radius': 500,
172+
'weight': 2,
172173
'line_color': 'black',
173174
'fill_color': 'black',
174175
'fill_opacity': 0.6})
175176
assert (''.join(circle_1.split())[:-1] in
176177
''.join(self.map.get_root().render().split()))
177178

178179
# Second circle marker.
179-
marker = folium.features.CircleMarker([45.70, -122.9], popup='Hi')
180+
marker = folium.features.CircleMarker([45.70, -122.9], popup='Hi', weight=1)
180181
self.map.add_child(marker)
181182
circle_2 = circ_templ.render({'circle': marker.get_name(),
182183
'lat': 45.70,
183184
'lon': -122.9, 'radius': 500,
185+
'weight': 1,
184186
'line_color': 'black',
185187
'fill_color': 'black',
186188
'fill_opacity': 0.6})

0 commit comments

Comments
 (0)