In Leaflet, I am trying to create a function that restores the initial position and zoom level of a layer containing coordinates. The code below
function refresh() {
map.fitBounds(coordLayer.getBounds();
}
centers the marker but is zoomed in to the maxZoom I had set:
var map = L.map('map').setView([lat, lon], 6);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' {
maxZoom: 13,
minZoom: 2,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
The default zoom level on page refresh is 6, but I don't know how to create a function that centers the marker at zoom level 6.