Marker with same ID results into broken html
snami100 opened this issue · comments
Describe the bug
When we create one single Icon for a Marker. And pass it to multiple Markers, the map would not display any markers at all.
All icons need to have unique ID's. That means for each marker I need to recreate a unique icon, even if its the same symbol.
Is it not possible to create one icon and pass it to every marker?
To Reproduce
def create_folium_object(
row: pd.Series, geometry_column: str, args: dict, geom_type: str
):
if geom_type == "Point":
args = copy.deepcopy(args)
if args.get("icon"):
# my current solution
args["icon"]._id = str(
hash(tuple([row[geometry_column].y, row[geometry_column].x]))
)
folium_object = fl.Marker(
location=[row[geometry_column].y, row[geometry_column].x], **args
)
else:
folium_object = fl.GeoJson(data=row[geometry_column], **args)
return folium_object
As you can see Im setting the ID by creating an hash value of the LAT LONs so that I have an unique ID for each icon. Otherwise the map would not work. Can you fix it? So that one icon can be created and used in different markers? Thanks
**Expected behavior**
A clear and concise description of what you expected to happen.
**Environment (please complete the following information):**
- Browser --> firefox
- Jupyter Notebook or html files? --> html
- Python version (check it with `import sys; print(sys.version_info)`) --> sys.version_info(major=3, minor=11, micro=4, releaselevel='final', serial=0)
- folium version (check it with `import folium; print(folium.__version__)`) --> 0.16.0
- branca version (check it with `import branca; print(branca.__version__)`) --> 0.7.1
This is indeed the case unfortunately. I'll close this issue since it's a duplicate of #744