From 28872f74eea6f598ca44f18170aaffcaae817f17 Mon Sep 17 00:00:00 2001 From: Owen Rees Date: Fri, 7 Jul 2023 14:29:09 +0200 Subject: [PATCH] world bounds --- app/[lang]/tournois/TournamentMap.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/[lang]/tournois/TournamentMap.tsx b/app/[lang]/tournois/TournamentMap.tsx index 6fbfb1b..091044c 100644 --- a/app/[lang]/tournois/TournamentMap.tsx +++ b/app/[lang]/tournois/TournamentMap.tsx @@ -55,6 +55,13 @@ const MapEvents = () => { setMapBounds(map.getBounds()); }); + // Set the maximum bounds of the map to prevent moving past the world + useEffect(() => { + const worldBounds = L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180)); + map.setMaxBounds(worldBounds); + map.options.maxBoundsViscosity = 1.0; // Prevents going past bounds while dragging + }, [map]); + return null; };