folium icon indicating copy to clipboard operation
folium copied to clipboard

map.save() to support an option to export leaflet dependencies (js/css/icons) as inline base64 uris

Open prusswan opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

folium maps exported as html still depend on external leaflet dependencies (either from internet or on relative paths - manual modification is needed)

Describe the solution you'd like

Something similar to knit in RStudio (which produces the html with the inlined resources). I believe the R leaflet package is self-contained (it contains leaflet's resources), so for this to work in the same manner in folium, additional options to override default_js/default_css may be necessary (i.e. to point them to relative/static paths).

Describe alternatives you've considered

Out of various leaflet wrappers, RStudio's implementation is the closest.

Additional context

(Could attach one of html files created through RStudio's leaflet, if anyone needs it)

Implementation

Possibly, just to gauge the interest for now

prusswan avatar Jul 04 '24 12:07 prusswan

This is an interesting idea. But how would that work with tiles? You can set up local tiles, but that's a bit more involved.

Conengmo avatar Jul 26 '24 15:07 Conengmo

This is an interesting idea. But how would that work with tiles? You can set up local tiles, but that's a bit more involved.

Ha, this is an "easy" one. Tiles are not part of leaflet's resources/dependencies, so they will continue to work in the same manner, with or without this enhancement.

prusswan avatar Jul 26 '24 17:07 prusswan

That’s fair :) but what’s the point of packing all the other resources then? I was thinking of the offline use case, but if that’s not the goal then what other use case are you thinking of?

Conengmo avatar Jul 27 '24 15:07 Conengmo

That’s fair :) but what’s the point of packing all the other resources then? I was thinking of the offline use case, but if that’s not the goal then what other use case are you thinking of?

It is one step towards the offline use case, but of course folium cannot be expected to carry an entire set of tiles. Also, depending on the nature of the data, basemap tiles might not be needed (e.g. if they have world outlines as a data layer). Another related use case would be to modify default_css/default_js which is not exposed as parameters.

prusswan avatar Jul 27 '24 17:07 prusswan