Skip to content

Commit

Permalink
fix(map): Restore layers from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Oct 24, 2024
1 parent 2b69a76 commit 1fb8181
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/containers/map/content/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const MainMap: FCWithMessages = () => {
const locale = useLocale();

const [{ bbox: URLBbox }, setMapSettings] = useSyncMapSettings();
const [, setMapLayers] = useSyncMapLayers();
const [mapLayers, setMapLayers] = useSyncMapLayers();
const { default: map } = useMap();
const drawState = useAtomValue(drawStateAtom);
const [popup, setPopup] = useAtom(popupAtom);
Expand Down Expand Up @@ -87,12 +87,13 @@ const MainMap: FCWithMessages = () => {
}
);

// Once we have fetched from the CMS which layers are active by default, we set toggle them on
// Once we have fetched from the CMS which layers are active by default, we set toggle them on, if
// there are already no layers in the URL
useEffect(() => {
if (defaultLayers) {
if (defaultLayers && mapLayers.length === 0) {
setMapLayers(defaultLayers);
}
}, [setMapLayers, defaultLayers]);
}, [mapLayers, setMapLayers, defaultLayers]);

const safelyResetFeatureState = useCallback(() => {
if (!hoveredPolygonId.current) {
Expand Down

0 comments on commit 1fb8181

Please sign in to comment.