-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
Comments
@rl-utility-man I managed to reproduce the error. The issue seems to be that there is a parent-child relationship between the A possible solution would be to add a |
Thanks @hansthen! Yes, I can take a look at a fix along the lines you recommend and either issue a pull request or circle back with questions. Give me a week or two. |
Duplicate of #744 it seems. I'll leave this one open since we have more recent discussion here. |
Hi @hansthen and @Conengmo, I've proposed Branca PR #186 to address this. I'd appreciate it if an appropriate member of the Branca/Folium team could look at that and advise about where to go next. Thanks! |
#744 was meant to solve this issue specifically for Marker and Icon. I now see we should also apply the same logic to DivIcon and CustomIcon. I'll open an issue for that. But having a clone method may still be useful, so I'll also look at your PR. |
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: