Note: This post assumes that you already have a Leaflet map set up and are thus, naturally, familiar with the basics of web development.
Why I make this?
Leaflet is fantastic. But as with a lot of open-source projects, it lacks a few features that you might be commonsense for you.
For me, that feature was a reset zoom button.
How to do this?
Simply add this code snippet to the JavaScript file where you’re initializing your Leaflet map. Or abstract the code into a separate file and import it.
You could even save the function’s output in a variable and add it to the map later, if that’s your style.