From c3cdcfd3790782058fe68621dda9f7eaa170c070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Thu, 4 Jun 2026 14:28:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E5=9C=B0=E5=9B=BE=E7=BC=A9?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meshmap_frontend/src/components/MeshMap.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/meshmap_frontend/src/components/MeshMap.vue b/meshmap_frontend/src/components/MeshMap.vue index d5866b1..a57a8cd 100644 --- a/meshmap_frontend/src/components/MeshMap.vue +++ b/meshmap_frontend/src/components/MeshMap.vue @@ -30,6 +30,12 @@ let map: L.Map | null = null let markerLayer: L.LayerGroup | null = null let hasFitBounds = false +const minMapZoom = 3 +const worldBounds = L.latLngBounds( + [-85.05112878, -180], + [85.05112878, 180], +) + onMounted(async () => { window.addEventListener('click', closeNodeMenu) window.addEventListener('keydown', handleKeydown) @@ -39,15 +45,16 @@ onMounted(async () => { } map = L.map(mapEl.value, { zoomControl: true, - maxBounds: [ - [-85, -180], - [85, 180], - ], + minZoom: minMapZoom, + maxBounds: worldBounds, maxBoundsViscosity: 1.0, worldCopyJump: false, - }).setView([0, 0], 2) + }).setView([0, 0], minMapZoom) L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + minZoom: minMapZoom, maxZoom: 19, + noWrap: true, + bounds: worldBounds, attribution: '© OpenStreetMap contributors', }).addTo(map) map.on('click', () => { @@ -179,7 +186,7 @@ function buildClusterMarker(cluster: MapClusterNode): L.Marker { marker.on('click', () => { closeNodeMenu() if (map) { - map.setView([cluster.latitude, cluster.longitude], Math.min(map.getZoom() + 2, map.getMaxZoom())) + map.setView([cluster.latitude, cluster.longitude], Math.max(minMapZoom, Math.min(map.getZoom() + 2, map.getMaxZoom()))) } }) return marker