python-visualization / folium

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

SideBySideLayers not displaying the layers #1846

Closed brunoparente93 closed 2 months ago

brunoparente93 commented 11 months ago

Describe the bug I am trying to use the folium plugin SideBySideLayers together with streamlit. In my app, I created 2 columns, so the users can select the layers they want to compare using the folium SideBySideLayers plugin.

The plugin works when I write the layer name, but it does not work when I add the argument layer in a variable or sometimes, it works only one side.

PS: the same happens with DualMap

To Reproduce

def layer_comparison(right, left):   #string variables
    url = "some url"

    m3 = folium.Map(location=[52.37361, 9.73783], zoom_start=11,tiles='cartodb positron')

    layer_right = folium.raster_layers.WmsTileLayer(
            url=url,
            name="Max Überflutunghohe (ohne Kanal 100a)",
            fmt="image/png",
            transparent=True,
            layers=right,
            overlay=True,
        )

    layer_left = folium.raster_layers.WmsTileLayer(
            url=url,
            name="Max Überflutunghohe (ohne Kanal 30a)",
            fmt="image/png",
            transparent=True,
            layers=left,
            overlay=True,
       )

    sbs = folium.plugins.SideBySideLayers(layer_left=layer_left, layer_right=layer_right)

    layer_left.add_to(m3)
    layer_right.add_to(m3)
    sbs.add_to(m3)
    return m3

layer_comparison('mk100','ok50')

Can someone help me to fix this issue?

Thank you in advance!

Conengmo commented 11 months ago

I can't reproduce your issue. Using WmsTileLayer with SideBySideLayers works for me as expected. Can you provide a fully standalone working example? I don't know what url you are using.

Is WmsTileLayer working when you add it to the map without SideBySideLayers?

Conengmo commented 2 months ago

I'll close this issue since it's stale and missing information. If new information comes up, we can reopen it.