import streamlit as st
from streamlit_folium import st_folium
import folium
m = folium.Map(location=[46.603354, 1.888334], zoom_start=6)
m.add_child(folium.LatLngPopup()) # to show the coordinates
st_folium(m, use_container_width=True, height=500, key='carte0', debug=True)
I think I need inject JS, but nothing works:
m.get_root().script.add_child(folium.Element("console.log('working perfectly');"))
And to remove, not better (and my solution is too radical)
script_delPoints = """<script>
var iframes = document.querySelectorAll('iframe');
iframes.forEach(function(iframe) {
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var popupPane = iframeDocument.querySelector('.leaflet-popup-pane');
if (popupPane) { popupPane.remove(); // Supprimer l'élément popup-pane du DOM
}
});
</script>
"""
m.get_root().script.add_child(folium.Element(script_delPoints))
I have view folium.JsCode()
but how use it ?
Thx in advance.
I have try lot of things, but I am blocked: (I am zero in JS)
m.get_root().script.add_child(folium.Element("console.log('working perfectly');"))
m.get_root().script.add_child(folium.Element("<script>console.log('working perfectly');</script>"))
st_folium(m, use_container_width=True, height=500, key='carte0', debug=True)
m.get_root().script.add_child(folium.Element("<script>console.log('working perfectly');</script>"))
m.get_root().script.add_child(folium.Element("console.log('working perfectly');"))