diff --git a/folium/features.py b/folium/features.py index 1c18f426d..f44840dc1 100644 --- a/folium/features.py +++ b/folium/features.py @@ -1718,7 +1718,6 @@ class DivIcon(MacroElement): """ {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.divIcon({{ this.options|tojavascript }}); - {{this._parent.get_name()}}.setIcon({{this.get_name()}}); {% endmacro %} """ ) # noqa @@ -1895,7 +1894,6 @@ class CustomIcon(Icon): """ {% macro script(this, kwargs) %} var {{ this.get_name() }} = L.icon({{ this.options|tojavascript }}); - {{ this._parent.get_name() }}.setIcon({{ this.get_name() }}); {% endmacro %} """ ) # noqa diff --git a/folium/map.py b/folium/map.py index e92290671..f2b8aa5ae 100644 --- a/folium/map.py +++ b/folium/map.py @@ -382,7 +382,9 @@ class SetIcon(MacroElement): """ ) - def __init__(self, marker: "Marker", icon: "Icon"): + def __init__( + self, marker: "Marker", icon: Union[Icon, "CustomIcon", "DivIcon"] + ): super().__init__() self._name = "SetIcon" self.marker = marker