How do I detect a click on a layer and find out information about the layer that was clicked?
Currently I can do the usual binding a popup and adding a click handler on the layer:
L.geoJson(data.streets, {
onEachFeature: function(feature, featureLayer) {
featureLayer.bindPopup(feature.properties.name);
featureLayer.on('click', function(e) {
console.log('Layer clicked!', e);
});
...
However the click handler on the layer doesn't give me any information about the layer, just the following:
containerPoint: o.Point
latlng: o.LatLng {
lat: 50.804443085898185,
lng: -1.089920997619629
}
__proto__: Object
layerPoint: o.Point
originalEvent: MouseEvent
target: e
type: "click"
__proto__: Object
How can I get a reference to the layer it's clicking?