-
Hi,
I cannot find username and password as parameters in the add_wms_layer function. How can I load such a WMS layer into leafmap? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Can you try it with ipyleaflet without leafmap? If it works with ipyleaflet, then we should be able to make it work with leafmap. Otherwise, it would be an upstream issue that should be reported to the ipylealfet repo. https://ipyleaflet.readthedocs.io/en/latest/layers/wms_layer.html |
Beta Was this translation helpful? Give feedback.
-
From ChatGPT. Not sure if it works. If not, it is an ipyleaflet issue. import ipyleaflet
from ipywidgets import HTML
# Define your WMS service URL and credentials
wms_url = "https://ogc-dev.sample.eu/geoserver/iride/wms?"
username = "your_username"
password = "your_password"
# Create a basic authentication header
auth_header = f"Basic {username}:{password}"
# Create the WMS layer
wms_layer = ipyleaflet.WMSLayer(
url=wms_url,
layers='your_layer_name',
format='image/png',
transparent=True,
attribution='WMS Service',
# Add the custom headers here
headers={'Authorization': auth_header}
)
# Create a map
m = ipyleaflet.Map(center=(0, 0), zoom=2)
# Add the WMS layer to the map
m.add_layer(wms_layer)
# Display the map
m |
Beta Was this translation helpful? Give feedback.
From ChatGPT. Not sure if it works. If not, it is an ipyleaflet issue.