prhbrt / folium-jsbutton

Add a button that executes JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to add Title to the Button

ar-siddiqui opened this issue · comments

image

Thanks for this great tool. I am looking for something like this.

I got it solved like this. Leaving the code here for anyone that may come here. Sorry, I am very new to folium and JS.

        # fit map to all layers bounds
        map_bounds = self.m.get_bounds()

        # add button to nevigate to map bound
        JsButton(
            title='<i class="fas fa-crosshairs" title="Map Center"></i>',
            function=f"""
            function(btn, map) {{
                map.fitBounds({map_bounds});
                btn.state('reset-zoom');
            }}
            """,
        ).add_to(self.m)