Creating an SVG divicon variable and using it in a marker works. Adding a second, marker that uses that variable causes neither to appear as expected #1885
Labels
bug
An issue describing unexpected or malicious behaviour
Describe the bug
If I pass the same object reference to Marker twice, it fails cryptically, but if I pass two distinct but identical objects to Marker, it succeeds
If I create one marker containing a variable that contains a DivIcon with an svg image tag, it works. If I add a second marker containing a different svg image tag -- even if the code underlying the divicon is identical, it will also work (see the left panel). But if I create a second marker containing the same svg icon variable, both of the icons fail (see the right panel).
For now, a viable workaround seems to be to avoid creating an icon variable and instead to just use:
I suspect based on some struggles I've had in the last few days, but have not confirmed, that this affects font-awesome DivIcons as well.
To Reproduce
I think the problem is in the following section of output:
Here is the last section of output for the working version:
Here is the last section of output for the failing version:
Expected behavior
Using one variable pointing at an svg icon variable in multiple maps should work. In other words, both maps should work.
The behavior should be the same and correct regardless of whether you specify
or
Right now, specifying
folium.Marker(...icon=icon...)
repeatedly will fail, but repeatingfolium.Marker(...icon=folium.DivIcon(...
works.Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Possible solutions
List any solutions you may have come up with.
folium is maintained by volunteers. Can you help making a fix for this issue?
Yes, I can try to help. Are these the relevant sections of code?
folium/folium/map.py
Line 363 in 226ba52
https://github.com/python-visualization/branca/blob/f3d866f598a194f9acd30e24e1affe52a32a9f05/branca/element.py#L129
The SVG icon I saved locally and used is:
The text was updated successfully, but these errors were encountered: