I have a Leaflet map containing overlapping GeoJSON layers. How can I identify all features at the location clicked?
See http://jsbin.com/zavuda/edit?html,js,output for a demo using Leaflet sample data.
Note that the Campus layer can be clicked when it's the top layer, and its attributes are shown via the layer's onEachFeature
function.
Then use the toggle under the map to switch on the States layer, which overlaps the Campus layer. After this the Campus layer can no longer be clicked on.
Is it possible to run an "identify" query at the location clicked by the user, and return all intersecting features?
Best Answer
Unless there is some built-in way of doing this that I'm not aware of, my rough approach would be to use something like leaflet-pip to do the following:
Leaflet-pip example: