Use `eachLayer`

Utilize Leaflet's built-in `eachLayer` function when iterating through
layers. Additionally, test if a layer's `on` or `off` method exists
before trying to invoke it.