Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filter toponyme in capture map #934

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions components/map/controls/image-control.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState, useEffect, Dispatch, SetStateAction } from "react";
import type { Map as MaplibreMap } from "maplibre-gl";
import {
Tooltip,
Expand All @@ -23,9 +23,16 @@ const poiLayersIds = ["poi-level-1", "poi-level-2", "poi-level-3"];
interface ImageControlProps {
map: MaplibreMap | null;
communeNom: string;
showToponyme: boolean;
setShowToponyme: Dispatch<SetStateAction<boolean>>;
}

function ImageControl({ map, communeNom }: ImageControlProps) {
function ImageControl({
map,
communeNom,
showToponyme,
setShowToponyme,
}: ImageControlProps) {
const [adresseLayerZoom, setAdresseLayerZoom] = useState([
ZOOM.NUMEROS_ZOOM.maxZoom,
]);
Expand Down Expand Up @@ -129,6 +136,7 @@ function ImageControl({ map, communeNom }: ImageControlProps) {
}, [map, poiLayerIsDisplayed]);

const initLayer = () => {
setShowToponyme(true);
setAdresseLayerIsDisplayed(true);
setVoieLayerIsDisplayed(true);
setPoiLayerIsDisplayed(true);
Expand Down Expand Up @@ -165,7 +173,7 @@ function ImageControl({ map, communeNom }: ImageControlProps) {
paddingRight={18}
paddingTop={12}
width={200}
height={210}
height={240}
display="flex"
flexDirection="column"
>
Expand All @@ -185,6 +193,12 @@ function ImageControl({ map, communeNom }: ImageControlProps) {
setZoom={setVoieLayerZoom}
/>

<LayerShowHideZoomControl
title="Toponymes"
isDiplayed={showToponyme}
setIsDiplayed={setShowToponyme}
/>

<LayerShowHideZoomControl
title="Points d‘intérets"
isDiplayed={poiLayerIsDisplayed}
Expand Down
11 changes: 9 additions & 2 deletions components/map/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@

const [cursor, setCursor] = useState("default");
const [isContextMenuDisplayed, setIsContextMenuDisplayed] = useState(null);
const [showToponyme, setShowToponyme] = useState(true);
const [mapStyle, setMapStyle] = useState(generateNewStyle(defaultStyle));

const { balId } = router.query;
Expand Down Expand Up @@ -230,7 +231,7 @@

setIsContextMenuDisplayed(null);
},
[router, balId, setEditingId, isEditing, voie, handleParcelle]

Check warning on line 234 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

React Hook useCallback has a missing dependency: 'map'. Either include it or remove the dependency array

Check warning on line 234 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

React Hook useCallback has a missing dependency: 'map'. Either include it or remove the dependency array

Check warning on line 234 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

React Hook useCallback has a missing dependency: 'map'. Either include it or remove the dependency array

Check warning on line 234 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (22.x)

React Hook useCallback has a missing dependency: 'map'. Either include it or remove the dependency array
);

useEffect(() => {
Expand Down Expand Up @@ -274,7 +275,7 @@
}
}
}
}, [map, style]);

Check warning on line 278 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

React Hook useEffect has a missing dependency: 'isTileSourceLoaded'. Either include it or remove the dependency array

Check warning on line 278 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

React Hook useEffect has a missing dependency: 'isTileSourceLoaded'. Either include it or remove the dependency array

Check warning on line 278 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

React Hook useEffect has a missing dependency: 'isTileSourceLoaded'. Either include it or remove the dependency array

Check warning on line 278 in components/map/map.tsx

View workflow job for this annotation

GitHub Actions / build (22.x)

React Hook useEffect has a missing dependency: 'isTileSourceLoaded'. Either include it or remove the dependency array

// Auto switch to ortho on draw and save previous style
useEffect(() => {
Expand Down Expand Up @@ -367,7 +368,12 @@

{!isMobile && (
<Pane position="absolute" zIndex={1} top={125} right={10}>
<ImageControl map={map} communeNom={commune.nom} />
<ImageControl
map={map}
communeNom={commune.nom}
showToponyme={showToponyme}
setShowToponyme={setShowToponyme}
/>
</Pane>
)}

Expand Down Expand Up @@ -424,7 +430,8 @@
/>
)}

{toponymes &&
{showToponyme &&
toponymes &&
viewport.zoom > TOPONYMES_MIN_ZOOM &&
toponymes.map((toponyme) => (
<ToponymeMarker
Expand Down
Loading