// Calculate bounds

var bounds = new L.LatLngBounds();
locations.forEach(function(location) {
    bounds.extend([location.lat, location.lng]);
});

// Set center to the midpoint of the bounds

var centerLatLng = bounds.getCenter();

var map = L.map('OSM-map', mapOptions).setView(centerLatLng, 1);

// Adjust the map to fit all markers within the bounds

map.fitBounds(bounds);

// Zoom out a bit more by decreasing the zoom level

map.setZoom(map.getZoom() - 1); // Decrease zoom level by 1