Skip to content

Commit ed69f9e

Browse files
committed
Merge pull request #133 from themiurgo/popup
Remove popup_on
2 parents 204d722 + 292f44c commit ed69f9e

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

folium/folium.py

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def add_layers_to_map(self):
293293
self.template_vars.setdefault('data_layers', []).append((data_string))
294294

295295
@iter_obj('simple')
296-
def simple_marker(self, location=None, popup='Pop Text', popup_on=True,
296+
def simple_marker(self, location=None, popup=None,
297297
marker_color='blue', marker_icon='info-sign',
298298
clustered_marker=False, icon_angle=0, width=300):
299299
"""Create a simple stock Leaflet marker on the map, with optional
@@ -308,8 +308,6 @@ def simple_marker(self, location=None, popup='Pop Text', popup_on=True,
308308
or a tuple of the form (Vincent object, 'vis_path.json')
309309
It is possible to adjust the width of text/HTML popups
310310
using the optional keywords `width`. (Leaflet default is 300px.)
311-
popup_on: boolean, default True
312-
Pass false for no popup information on the marker
313311
marker_color
314312
color of marker you want
315313
marker_icon
@@ -350,8 +348,7 @@ def simple_marker(self, location=None, popup='Pop Text', popup_on=True,
350348
})
351349

352350
popup_out = self._popup_render(popup=popup, mk_name='marker_',
353-
count=count, popup_on=popup_on,
354-
width=width)
351+
count=count, width=width)
355352
if clustered_marker:
356353
add_mark = 'clusteredmarkers.addLayer(marker_{0})'.format(count)
357354
name = 'cluster_markers'
@@ -364,7 +361,7 @@ def simple_marker(self, location=None, popup='Pop Text', popup_on=True,
364361
@iter_obj('line')
365362
def line(self, locations,
366363
line_color=None, line_opacity=None, line_weight=None,
367-
popup='Pop Text', popup_on=True, popup_width=300):
364+
popup=None, popup_width=300):
368365
"""Add a line to the map with optional styles.
369366
370367
Parameters
@@ -377,8 +374,6 @@ def line(self, locations,
377374
popup: string or tuple, default 'Pop Text'
378375
Input text or visualization for object. Can pass either text,
379376
or a tuple of the form (Vincent object, 'vis_path.json')
380-
popup_on: boolean, default True
381-
Pass false for no popup information on the marker
382377
383378
Note: If the optional styles are omitted, they will not be included
384379
in the HTML output and will obtain the Leaflet defaults listed above.
@@ -403,8 +398,7 @@ def line(self, locations,
403398
'options': polyline_opts})
404399

405400
popup_out = self._popup_render(popup=popup, mk_name='line_',
406-
count=count, popup_on=popup_on,
407-
width=popup_width)
401+
count=count, width=popup_width)
408402

409403
add_line = 'map.addLayer({});'.format(varname)
410404
append = (line_rendered, popup_out, add_line)
@@ -459,8 +453,8 @@ def multiline(self, locations, line_color=None, line_opacity=None,
459453
self.template_vars.setdefault('multilines', []).append(append)
460454

461455
@iter_obj('circle')
462-
def circle_marker(self, location=None, radius=500, popup='Pop Text',
463-
popup_on=True, line_color='black', fill_color='black',
456+
def circle_marker(self, location=None, radius=500, popup=None,
457+
line_color='black', fill_color='black',
464458
fill_opacity=0.6):
465459
"""Create a simple circle marker on the map, with optional popup text
466460
or Vincent visualization.
@@ -474,8 +468,6 @@ def circle_marker(self, location=None, radius=500, popup='Pop Text',
474468
popup: string or tuple, default 'Pop Text'
475469
Input text or visualization for object. Can pass either text,
476470
or a tuple of the form (Vincent object, 'vis_path.json')
477-
popup_on: boolean, default True
478-
Pass false for no popup information on the marker
479471
line_color: string, default black
480472
Line color. Can pass hex value here as well.
481473
fill_color: string, default black
@@ -507,8 +499,7 @@ def circle_marker(self, location=None, radius=500, popup='Pop Text',
507499
'fill_opacity': fill_opacity})
508500

509501
popup_out = self._popup_render(popup=popup, mk_name='circle_',
510-
count=count,
511-
popup_on=popup_on)
502+
count=count)
512503

513504
add_mark = 'map.addLayer(circle_{0})'.format(count)
514505

@@ -519,8 +510,7 @@ def circle_marker(self, location=None, radius=500, popup='Pop Text',
519510
@iter_obj('polygon')
520511
def polygon_marker(self, location=None, line_color='black', line_opacity=1,
521512
line_weight=2, fill_color='blue', fill_opacity=1,
522-
num_sides=4, rotation=0, radius=15, popup='Pop Text',
523-
popup_on=True):
513+
num_sides=4, rotation=0, radius=15, popup=None):
524514
"""Custom markers using the Leaflet Data Vis Framework.
525515
526516
@@ -547,8 +537,6 @@ def polygon_marker(self, location=None, line_color='black', line_opacity=1,
547537
popup: string or tuple, default 'Pop Text'
548538
Input text or visualization for object. Can pass either text,
549539
or a tuple of the form (Vincent object, 'vis_path.json')
550-
popup_on: boolean, default True
551-
Pass false for no popup information on the marker
552540
553541
Returns
554542
-------
@@ -573,8 +561,7 @@ def polygon_marker(self, location=None, line_color='black', line_opacity=1,
573561
'radius': radius})
574562

575563
popup_out = self._popup_render(popup=popup, mk_name='polygon_',
576-
count=count,
577-
popup_on=popup_on)
564+
count=count)
578565

579566
add_mark = 'map.addLayer(polygon_{0})'.format(count)
580567

@@ -665,7 +652,7 @@ def fit_bounds(self, bounds, padding_top_left=None,
665652

666653

667654
def _popup_render(self, popup=None, mk_name=None, count=None,
668-
popup_on=True, width=300):
655+
width=300):
669656
"""Popup renderer: either text or Vincent/Vega.
670657
671658
Parameters
@@ -676,11 +663,9 @@ def _popup_render(self, popup=None, mk_name=None, count=None,
676663
Type of marker. Simple, Circle, etc.
677664
count: int, default None
678665
Count of marker
679-
popup_on: boolean, default True
680-
If False, no popup will be rendered
681666
"""
682-
if not popup_on:
683-
return 'var no_pop = null;'
667+
if not popup:
668+
return ''
684669
else:
685670
if sys.version_info >= (3, 0):
686671
utype, stype = str, bytes

tests/folium_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_simple_marker(self):
154154
'pop_txt': json.dumps('Pop Text'),
155155
'width': 300})
156156
assert self.map.template_vars['custom_markers'][0][1] == mark_1
157-
assert self.map.template_vars['custom_markers'][0][2] == popup_1
157+
assert self.map.template_vars['custom_markers'][0][2] == ""
158158

159159
# Test Simple marker addition.
160160
self.map.simple_marker(location=[45.60, -122.8], popup='Hi')
@@ -169,8 +169,8 @@ def test_simple_marker(self):
169169
assert self.map.template_vars['custom_markers'][1][2] == popup_2
170170

171171
# Test no popup.
172-
self.map.simple_marker(location=[45.60, -122.8], popup_on=False)
173-
nopopup = 'var no_pop = null;'
172+
self.map.simple_marker(location=[45.60, -122.8])
173+
nopopup = ''
174174
assert self.map.template_vars['custom_markers'][2][2] == nopopup
175175

176176
def test_circle_marker(self):

0 commit comments

Comments
 (0)