diff --git a/CHANGELOG.md b/CHANGELOG.md index 6454e6c1..3190340b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to ### Added - cli: Add auto-paging to `dump`, `schema` and all view commands (#138). +- web: Adjust datacenters map zoom level to fit their markers locations (#78). - docs: - Mention support of Fedora 42. - Mention support of Debian 14 _« forky »_ diff --git a/frontend/src/views/DatacentersView.vue b/frontend/src/views/DatacentersView.vue index f70ecdea..103f1933 100644 --- a/frontend/src/views/DatacentersView.vue +++ b/frontend/src/views/DatacentersView.vue @@ -54,10 +54,12 @@ function datacentersMapConfig() { // Configuration of the map const map = L.map(mapContainer.value).setView([averageLatitude, averageLongitude], 5) L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { - maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map) + // Prepare bounds to fit all markers + const bounds = L.latLngBounds([]) + // Add a marker on a map if the datacenter has coordinates datacenters.value.forEach((datacenter) => { // Skip datacenter if location is not defined @@ -80,6 +82,7 @@ function datacentersMapConfig() { let marker = L.marker([datacenter.location.latitude, datacenter.location.longitude], { icon: purpleIcon }).addTo(map) + bounds.extend([datacenter.location.latitude, datacenter.location.longitude]) marker.bindPopup( `
@@ -90,6 +93,9 @@ function datacentersMapConfig() {
` ) }) + + // Adjust the map view to include all markers + map.fitBounds(bounds, { padding: [10, 10] }) } onMounted(async () => {