File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -408,8 +408,7 @@ def __init__(
408
408
# this attribute is not used by Marker, but by GeoJson
409
409
self .icon = None
410
410
if icon is not None :
411
- self .add_child (icon )
412
- self .icon = icon
411
+ self .set_icon (icon )
413
412
if popup is not None :
414
413
self .add_child (popup if isinstance (popup , Popup ) else Popup (str (popup )))
415
414
if tooltip is not None :
@@ -434,6 +433,19 @@ def render(self):
434
433
self .add_child (self .SetIcon (marker = self , icon = self .icon ))
435
434
super ().render ()
436
435
436
+ def set_icon (self , icon : Union [Icon , "CustomIcon" , "DivIcon" ]):
437
+ """Set the icon for this Marker"""
438
+ super ().add_child (icon )
439
+ self .icon = icon
440
+
441
+ def add_child (self , child , name = None , index = None ):
442
+ import folium .features as features
443
+
444
+ if isinstance (child , (Icon , features .CustomIcon , features .DivIcon )):
445
+ self .set_icon (child )
446
+ else :
447
+ super ().add_child (child , name , index )
448
+
437
449
438
450
class Popup (MacroElement ):
439
451
"""Create a Popup instance that can be linked to a Layer.
You can’t perform that action at this time.
0 commit comments