Retain current zoom when switching campaigns

This commit is contained in:
Raffson 2024-05-18 20:24:55 +02:00
parent 0f612ac9d9
commit 0f9781ff30
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -25,10 +25,10 @@ export default function LiberationMap() {
const map = useRef<Map>(null);
const mapCenter = useAppSelector(selectMapCenter);
useEffect(() => {
map.current?.setView(mapCenter, 8, { animate: true, duration: 1 });
map.current?.setView(mapCenter, map.current?.getZoom() ?? 8, { animate: true, duration: 1 });
});
return (
<MapContainer zoom={8} zoomControl={false} ref={map}>
<MapContainer zoom={map.current?.getZoom() ?? 8} zoomControl={false} ref={map}>
<ScaleControl />
<LeafletRuler />
<LayersControl collapsed={false}>