I have a WMS layer that I display with ipyleaflet.
I would like to print the attributes of the figure on which I click.
I know QGIS does that under the hood but I didn't manage to access the code doing that.
It is calling wgs.getfeatureinfo() but I haven't been successful in reproducing it.
Do you know how that could be handled ?
Here is my code to display the map:
from ipyleaflet import Map, WMSLayer, basemaps
from ipywidgets import HTML
# Create a function to handle click events
def click_handler(event=None, feature=None, id=None, properties=None):
info = wms.get_feature_info()
print(info)
# Define the WMS layer
wms_url = "https://glims.org/geoserver/ows?SERVICE=WMS&"
wms = WMSLayer(
url=wms_url,
layers='GLIMS:RGI',
transparent=True,
format='image/png'
)
# Create the map
m = Map(basemap=basemaps.CartoDB.Positron, center=(38.491, -95.712), zoom=4)
# Add the WMS layer to the map
m.add_layer(wms)
m