From 3a0689fd2c30671a4b99416b362017235061ce54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Barrenechea=20S=C3=A1nchez?= Date: Mon, 11 Dec 2023 18:03:21 +0100 Subject: [PATCH] Markers tooltip --- .../components/map/layers/marker/index.tsx | 71 ++++++++++++++----- client/src/containers/map/index.tsx | 7 +- .../map/tooltips/home-tooltip/index.tsx | 2 - client/src/styles/mapbox.css | 21 +++--- 4 files changed, 67 insertions(+), 34 deletions(-) diff --git a/client/src/components/map/layers/marker/index.tsx b/client/src/components/map/layers/marker/index.tsx index 45408e1..4cd54bc 100644 --- a/client/src/components/map/layers/marker/index.tsx +++ b/client/src/components/map/layers/marker/index.tsx @@ -1,26 +1,63 @@ +import { MouseEventHandler } from 'react'; + import { Marker as RMarker, MarkerProps as RMarkerProps } from 'react-map-gl'; import { cn } from '@/lib/classnames'; -const Marker = (props: RMarkerProps) => { +import { Button } from '@/components/ui/button'; +import CategoryIcon from '@/components/ui/category-icon'; +import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; + +type MarkerProps = RMarkerProps & { + properties: GeoJSON.GeoJsonProperties; + onClick: MouseEventHandler; +}; + +const Marker = (props: MarkerProps) => { + const { properties, onClick } = props; return ( -
-
-
-
-
+ + +
+
+
+
+
+
+ +
e.stopPropagation()}> +
+ +

{properties?.categoryName}

+
+

{properties?.title}

+

{properties?.location}

+ + +
+
+
); }; diff --git a/client/src/containers/map/index.tsx b/client/src/containers/map/index.tsx index a494c8a..fba3740 100644 --- a/client/src/containers/map/index.tsx +++ b/client/src/containers/map/index.tsx @@ -19,7 +19,6 @@ import { layersInteractiveIdsAtom, // popupAtom, tmpBboxAtom, - isFlyingBackAtom, } from '@/store'; // import { useGetLayers } from '@/types/generated/layer'; @@ -40,10 +39,9 @@ import Map from '@/components/map'; // import Controls from '@/components/map/controls'; // import SettingsControl from '@/components/map/controls/settings'; // import ZoomControl from '@/components/map/controls/zoom'; +import Marker from '@/components/map/layers/marker'; import { CustomMapProps } from '@/components/map/types'; -import HomeTooltip from './tooltips/home-tooltip'; - const LayerManager = dynamic(() => import('@/containers/map/layer-manager'), { ssr: false, }); @@ -155,7 +153,6 @@ export default function MapContainer() { const f = e.features[0]; if (f.source === 'story-markers') { - console.log('f', f); setMarker({ ...f, geometry: f.geometry as GeoJSON.Point, @@ -234,7 +231,7 @@ export default function MapContainer() { {isHomePage && } {marker && isHomePage && ( - { const { properties, onClick } = props; - console.log({ props }); - return (