Skip to content

Commit 2ea6abc

Browse files
Conengmohansthen
andauthored
Fix icon when passing Marker to GeoJson (#2086)
* fix geojson marker icon * mypy * ruff * After review comments --------- Co-authored-by: Hans Then <hans.then@gmail.com>
1 parent 4b77743 commit 2ea6abc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

folium/map.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,11 @@ def __init__(
403403
self.options = remove_empty(
404404
draggable=draggable or None, autoPan=draggable or None, **kwargs
405405
)
406+
# this attribute is not used by Marker, but by GeoJson
407+
self.icon = None
406408
if icon is not None:
407409
self.add_child(icon)
410+
self.icon = icon
408411
if popup is not None:
409412
self.add_child(popup if isinstance(popup, Popup) else Popup(str(popup)))
410413
if tooltip is not None:
@@ -421,15 +424,12 @@ def _get_self_bounds(self) -> TypeBoundsReturn:
421424
return cast(TypeBoundsReturn, [self.location, self.location])
422425

423426
def render(self):
424-
from .features import CustomIcon, DivIcon
425-
426427
if self.location is None:
427428
raise ValueError(
428429
f"{self._name} location must be assigned when added directly to map."
429430
)
430-
for child in list(self._children.values()):
431-
if isinstance(child, (Icon, CustomIcon, DivIcon)):
432-
self.add_child(self.SetIcon(marker=self, icon=child))
431+
if self.icon:
432+
self.add_child(self.SetIcon(marker=self, icon=self.icon))
433433
super().render()
434434

435435

0 commit comments

Comments
 (0)