From f2ba798764b273fb287aedef4bed5129d3eb5305 Mon Sep 17 00:00:00 2001 From: rouggy Date: Sun, 30 Aug 2026 22:18:27 +0200 Subject: [PATCH] fix(maps): zooming stays centred on the grid and decode maps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hard maxBounds added for the single-world look fought the zoom: with the world smaller than the window the clamp dragged every zoom step into a corner. The noWrap tiles already guarantee one world on their own, so the bounds go — on both maps. --- frontend/src/components/FTMapPanel.tsx | 4 ++-- frontend/src/components/GridSquareMap.tsx | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/FTMapPanel.tsx b/frontend/src/components/FTMapPanel.tsx index 908f074..1d25dce 100644 --- a/frontend/src/components/FTMapPanel.tsx +++ b/frontend/src/components/FTMapPanel.tsx @@ -55,10 +55,10 @@ export function FTMapPanel({ decodes, myGrid }: { decodes: FTMapDecode[]; myGrid // and the space beyond the edge is the theme's own surface (style.css). const m = L.map(divRef.current, { zoomControl: true, attributionControl: true, + // No maxBounds: with the world smaller than the window the clamp + // dragged every zoom into a corner. noWrap tiles alone keep one world. worldCopyJump: false, preferCanvas: true, center: [25, 0], zoom: 2, minZoom: 2, - maxBounds: L.latLngBounds(L.latLng(-85.0511, -180), L.latLng(85.0511, 180)), - maxBoundsViscosity: 1, }); mapRef.current = m; layerRef.current = L.layerGroup().addTo(m); diff --git a/frontend/src/components/GridSquareMap.tsx b/frontend/src/components/GridSquareMap.tsx index ab71c8c..ffd6e0e 100644 --- a/frontend/src/components/GridSquareMap.tsx +++ b/frontend/src/components/GridSquareMap.tsx @@ -128,15 +128,11 @@ export function GridSquareMap({ myGrid, className }: { myGrid?: string; classNam // impossible on any window wider than it is tall: one step out was already // too far in. minZoom: 0, - maxBoundsViscosity: 1, // don't let a drag slide the world off to one side + }).setView([20, 0], 2); // The whole world, once, whatever the window is shaped like — computed by // Leaflet from the container rather than guessed with a zoom number. m.fitWorld({ animate: false }); - // Latitude only: the poles are the edge of the projection and there is - // nothing beyond them, while leaving longitude free keeps a drag from - // fighting the operator near the date line. - m.setMaxBounds(L.latLngBounds(L.latLng(-85, -Infinity), L.latLng(85, Infinity))); mapRef.current = m; layerRef.current = L.layerGroup().addTo(m); // Leaflet measures its container ONCE, when the map is created, and never