[GIS] Leaflet: A way to show information of overlapping polygon of the same layer

leafletpopup

I have a polygon layer with overlapping polygons. When clicking on a spot with more than one polygon eg. overlapping polygons, the popup shows the property of only one feature (the topmost?). Is there a way to show the content of the same attribute of several objects in one popup?

Best Answer

onEachFeature is the issue, you tied a single popup to each feature and you can only click on one at a time. The traditional popup will not work. To select more then one polygon, you have to use a map on Click, and grab the coordinates and use them in a point in poly loop, this will let you grab all the polygons the point touches.

Now you can open a div like a popup and put the results in it. Or put a table on a side panel and put the results there. It's not a real popup solution but you are not clicking on a single polygon.