mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
world bounds
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user