world bounds

This commit is contained in:
Owen Rees
2023-07-07 14:29:09 +02:00
parent 7bc20846c9
commit 28872f74ee
+7
View File
@@ -55,6 +55,13 @@ const MapEvents = () => {
setMapBounds(map.getBounds()); 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; return null;
}; };