Could someone please explain me what is the difference betweenndeachLayer
and onEachFeature
. It's very confusing to me. I have read the leaflet documentation and it becomes more confusing.
The Leaflet eachLayer
method applies to any Layer Group. It loops on the group child layers at the time it is called only.
The onEachFeature
option applies to Leaflet GeoJSON Layer Group only. It executes on the group child layers after those are created, but note that the GeoJSON Layer Group can also receive more Features later on (through its addData
method), leading to creation of more child layers, each going through the onEachFeature
option again as well.