From 5f22dbe87b9d574970eecb1ee7d41d62d198ca7b Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Wed, 27 Sep 2023 16:26:41 +0200 Subject: [PATCH] Links details Viewpoints and map interaction --- frontend/src/components/Map/DetailsMap/DetailsMap.tsx | 7 +++++++ .../src/components/Map/DetailsMap/MapChildren.tsx | 11 ++++++++++- .../src/components/Map/DetailsMap/useDetailsMap.tsx | 4 ++++ .../components/DetailsMedias/DetailsMedias.tsx | 11 +++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Map/DetailsMap/DetailsMap.tsx b/frontend/src/components/Map/DetailsMap/DetailsMap.tsx index 4decfa135..34bd4a797 100644 --- a/frontend/src/components/Map/DetailsMap/DetailsMap.tsx +++ b/frontend/src/components/Map/DetailsMap/DetailsMap.tsx @@ -126,6 +126,8 @@ export const DetailsMap: React.FC = props => { toggleServiceVisibility, infrastructureVisibility, toggleInfrastructureVisibility, + viewPointVisibility, + toggleViewPointVisibility, annotationViewpointVisibility, toggleAnnotationViewpointVisibility, } = useDetailsMap(); @@ -255,6 +257,7 @@ export const DetailsMap: React.FC = props => { props.service && props.service.length > 0 ? serviceVisibility : null } infrastructureVisibility={props.infrastructure ? infrastructureVisibility : null} + viewPointVisibility={props.viewPoints ? viewPointVisibility : null} toggleTrekChildrenVisibility={toggleTrekChildrenVisibility} togglePoiVisibility={togglePoiVisibility} toggleReferencePointsVisibility={toggleReferencePointsVisibility} @@ -265,6 +268,7 @@ export const DetailsMap: React.FC = props => { toggleSignageVisibility={toggleSignageVisibility} toggleServiceVisibility={toggleServiceVisibility} toggleInfrastructureVisibility={toggleInfrastructureVisibility} + toggleViewPointVisiblity={toggleViewPointVisibility} /> {props.trekGeometry && ( = props => { signageVisibility={signageVisibility} serviceVisibility={serviceVisibility} infrastructureVisibility={infrastructureVisibility} + viewPoints={props.viewPoints} + viewPointVisibility={viewPointVisibility} + setMapId={props.setMapId} /> {props.displayAltimetricProfile === true && props.trekGeoJSON && ( diff --git a/frontend/src/components/Map/DetailsMap/MapChildren.tsx b/frontend/src/components/Map/DetailsMap/MapChildren.tsx index cb67f46f3..4c5889a2f 100644 --- a/frontend/src/components/Map/DetailsMap/MapChildren.tsx +++ b/frontend/src/components/Map/DetailsMap/MapChildren.tsx @@ -6,9 +6,10 @@ import { OutdoorSite } from 'modules/outdoorSite/interface'; import { SensitiveAreaGeometry } from 'modules/sensitiveArea/interface'; import { SignageDictionary } from 'modules/signage/interface'; import { InfrastructureDictionary } from 'modules/infrastructure/interface'; -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { useMediaPredicate } from 'react-media-hook'; import { Infrastructure } from 'components/Icons/Infrastructure'; +import { ViewPoint } from 'modules/viewPoint/interface'; import { GeometryListProps } from './DetailsMap'; import { MarkersWithIcon } from './MarkersWithIcon'; @@ -20,6 +21,7 @@ import { SensitiveAreas } from './SensitiveAreas'; import { GeometryList } from './GeometryList'; import { TrekChildren } from './TrekChildren'; import { Visibility } from './useDetailsMap'; +import ViewPointMarkers from './ViewPointMarkers'; export interface PointWithIcon { location: { x: number; y: number }; @@ -52,6 +54,9 @@ type Props = { service?: PointWithIcon[]; infrastructureVisibility: Visibility; infrastructure?: InfrastructureDictionary | null; + viewPointVisibility?: Visibility; + viewPoints?: ViewPoint[]; + setMapId?: (id: string) => void; }; export const MapChildren: React.FC = props => { @@ -122,6 +127,10 @@ export const MapChildren: React.FC = props => { {props.serviceVisibility === 'DISPLAYED' && } {(isMobile || visibleSection === 'report') && props.reportVisibility && } + + {(props.viewPointVisibility === 'DISPLAYED' || visibleSection === 'medias') && ( + + )} ); }; diff --git a/frontend/src/components/Map/DetailsMap/useDetailsMap.tsx b/frontend/src/components/Map/DetailsMap/useDetailsMap.tsx index c2de58632..3d26b73ba 100644 --- a/frontend/src/components/Map/DetailsMap/useDetailsMap.tsx +++ b/frontend/src/components/Map/DetailsMap/useDetailsMap.tsx @@ -21,6 +21,7 @@ export const useDetailsMap = () => { const [signageVisibility, setSignageVisibility] = useState('HIDDEN'); const [serviceVisibility, setServiceVisibility] = useState('HIDDEN'); const [infrastructureVisibility, setInfrastructureVisibility] = useState('HIDDEN'); + const [viewPointVisibility, setViewPointVisibility] = useState('HIDDEN'); const [annotationViewpointVisibility, setAnnotationViewpointVisibility] = useState('DISPLAYED'); @@ -39,6 +40,7 @@ export const useDetailsMap = () => { const toggleSignageVisibility = () => setSignageVisibility(toggleVisibility); const toggleServiceVisibility = () => setServiceVisibility(toggleVisibility); const toggleInfrastructureVisibility = () => setInfrastructureVisibility(toggleVisibility); + const toggleViewPointVisibility = () => setViewPointVisibility(toggleVisibility); const toggleAnnotationViewpointVisibility = () => setAnnotationViewpointVisibility(toggleVisibility); @@ -63,6 +65,8 @@ export const useDetailsMap = () => { toggleServiceVisibility, infrastructureVisibility, toggleInfrastructureVisibility, + viewPointVisibility, + toggleViewPointVisibility, annotationViewpointVisibility, toggleAnnotationViewpointVisibility, }; diff --git a/frontend/src/components/pages/details/components/DetailsMedias/DetailsMedias.tsx b/frontend/src/components/pages/details/components/DetailsMedias/DetailsMedias.tsx index 8e70acc75..ef74b29ff 100644 --- a/frontend/src/components/pages/details/components/DetailsMedias/DetailsMedias.tsx +++ b/frontend/src/components/pages/details/components/DetailsMedias/DetailsMedias.tsx @@ -6,6 +6,8 @@ import { FormattedMessage } from 'react-intl'; import { cn } from 'services/utils/cn'; import { Minus } from 'components/Icons/Minus'; import { Plus } from 'components/Icons/Plus'; +import { useListAndMapContext } from 'modules/map/ListAndMapContext'; +import { ViewPoint as ViewPointIcon } from 'components/Icons/ViewPoint'; interface DetailsMediasProps { className?: string; @@ -38,6 +40,8 @@ export const DetailsMedias: React.FC = ({ return null; } + const { setHoveredCardId } = useListAndMapContext(); + return (
= ({ TitleTag === 'h2' ? 'text-Mobile-H1 desktop:text-H2' : 'text-Mobile-C1 desktop:text-H4', )} > + {asAccordion && (