fix(maps): zooming stays centred on the grid and decode maps
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.
This commit is contained in:
@@ -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).
|
// and the space beyond the edge is the theme's own surface (style.css).
|
||||||
const m = L.map(divRef.current, {
|
const m = L.map(divRef.current, {
|
||||||
zoomControl: true, attributionControl: true,
|
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,
|
worldCopyJump: false, preferCanvas: true,
|
||||||
center: [25, 0], zoom: 2, minZoom: 2,
|
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;
|
mapRef.current = m;
|
||||||
layerRef.current = L.layerGroup().addTo(m);
|
layerRef.current = L.layerGroup().addTo(m);
|
||||||
|
|||||||
@@ -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
|
// impossible on any window wider than it is tall: one step out was already
|
||||||
// too far in.
|
// too far in.
|
||||||
minZoom: 0,
|
minZoom: 0,
|
||||||
maxBoundsViscosity: 1, // don't let a drag slide the world off to one side
|
|
||||||
}).setView([20, 0], 2);
|
}).setView([20, 0], 2);
|
||||||
// The whole world, once, whatever the window is shaped like — computed by
|
// The whole world, once, whatever the window is shaped like — computed by
|
||||||
// Leaflet from the container rather than guessed with a zoom number.
|
// Leaflet from the container rather than guessed with a zoom number.
|
||||||
m.fitWorld({ animate: false });
|
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;
|
mapRef.current = m;
|
||||||
layerRef.current = L.layerGroup().addTo(m);
|
layerRef.current = L.layerGroup().addTo(m);
|
||||||
// Leaflet measures its container ONCE, when the map is created, and never
|
// Leaflet measures its container ONCE, when the map is created, and never
|
||||||
|
|||||||
Reference in New Issue
Block a user