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__(
408408 # this attribute is not used by Marker, but by GeoJson
409409 self .icon = None
410410 if icon is not None :
411- self .add_child (icon )
412- self .icon = icon
411+ self .set_icon (icon )
413412 if popup is not None :
414413 self .add_child (popup if isinstance (popup , Popup ) else Popup (str (popup )))
415414 if tooltip is not None :
@@ -434,6 +433,19 @@ def render(self):
434433 self .add_child (self .SetIcon (marker = self , icon = self .icon ))
435434 super ().render ()
436435
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+
437449
438450class Popup (MacroElement ):
439451 """Create a Popup instance that can be linked to a Layer.
You can’t perform that action at this time.
0 commit comments