python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.85k stars 2.22k forks source link

GlifyLayer not defined when using .add_to(map) #1982

Open Doyley1 opened 2 months ago

Doyley1 commented 2 months ago

When using GlifyLayer.add_to(map) an error appears:

Uncaught ReferenceError: glify_layer_xxxxxx is not defined

The issue being that calling add_to(map) generates the function twice

L.glify.layer(options).addTo(map_xxxxxx); 
glify_layer_xxxxxx.addTo(map_xxxxxx);

This prevents the rest of the map loading correctly.

To Reproduce This can be reproduced using the GlifyLayer.ipynb by saving the resultant html to file and inspecting console

Environment:

Possible solutions A workaround I have been implementing is to directly change the HTML directly by setting

var glify_layer_xxxxxx = L.glify.layer(options);
glify_layer_xxxxxx.addTo(map_xxxxxx);

folium is maintained by volunteers. Can you help making a fix for this issue? Unsure of where the generation of the 2nd function glify_layer_xxxxxx.addTo(map_xxxxxx); is taking place, clearly not in init.py for GlifyLayer (Maybe constructor for GlifyLayer, but cannot be sure)

Conengmo commented 2 months ago

Thanks for the bug report! This is an issue in a downstream plugin. I opened a fix there: https://github.com/onaci/folium-glify-layer/pull/3

Doyley1 commented 2 months ago

Thanks for working on the fix :) any chance that documentation on this plugin can be added? Currently only mentioned within the ReadMe.md

Conengmo commented 2 months ago

No problem! About the documentation though, it’s not our plug-in, so you’d have to ask in the downstream repo.