2

I need to add interactivity to several WMS layers using leaflet, the problem i have is how i can identify what layer the user is clicking, i usually use geojson for this and is easy, but for WMS layers how i can achieve this?

I have seen this question, i guess i can iterate over the layers but then again how i can know which one is the one i need?

2

WMS layers are raster - which means they are images, even if they have transparent pixels.

In other words: if a user clicks on a transparent pixel on a WMS layer, she is still clicking on the WMS layer. The only exception is clicking outside of the layer bounds.

You might want to run a getFeatureInfo WMS request on the top-most WMS layer, see if there is any meaningful result at the clicked point, then iterate through other layers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.