From 8de56fcd6a2bb8560b6199e48f264602629afadb Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Thu, 5 Sep 2024 17:25:38 +0200 Subject: [PATCH] feat: Add minimap --- website/ambient.d.ts | 3 +- website/src/components/Mutations/Minimap.tsx | 53 ++++++++++++++++++++ website/src/pages/mutations.tsx | 52 ++++++++++++++----- 3 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 website/src/components/Mutations/Minimap.tsx diff --git a/website/ambient.d.ts b/website/ambient.d.ts index 27a86c35..d2cf6ea2 100644 --- a/website/ambient.d.ts +++ b/website/ambient.d.ts @@ -27,9 +27,10 @@ declare module "@deck.gl/layers" { export const GeoJsonLayer: $FixMe; export const LineLayer: $FixMe; export const PathLayer: $FixMe; + export const ScatterplotLayer: $FixMe; } declare module "@deck.gl/react" { export const DeckGL: $FixMe; export default DeckGL; -} \ No newline at end of file +} diff --git a/website/src/components/Mutations/Minimap.tsx b/website/src/components/Mutations/Minimap.tsx new file mode 100644 index 00000000..e0cf9870 --- /dev/null +++ b/website/src/components/Mutations/Minimap.tsx @@ -0,0 +1,53 @@ +import { GeoJsonLayer, ScatterplotLayer } from "@deck.gl/layers"; +import DeckGL from "@deck.gl/react"; +import { useGeoData } from "src/domain/geodata"; + +const Minimap = ({ + viewState, + extentViewState, +}: { + viewState: { longitude: number; latitude: number; zoom: number }; + extentViewState: { longitude: number; latitude: number; zoom: number }; +}) => { + const { data: geoDataMinimap } = useGeoData({ + year: "2022", + format: "topojson", + simplify: 0.02, + shapes: new Set(["country"]), + projection: "wgs84", + color: "default", + dimensions: { width: 800, height: 600 }, + withName: false, + }); + + return ( + + + 10000} + getPosition={(d) => d.coordinates} + getFillColor={[0, 0, 255, 50]} + getLineColor={[0, 0, 0]} + getLineWidth={10} + data={[ + { + coordinates: [extentViewState.longitude, extentViewState.latitude], + }, + ]} + /> + + ); +}; + +export default Minimap; diff --git a/website/src/pages/mutations.tsx b/website/src/pages/mutations.tsx index cdd59872..9c731c38 100644 --- a/website/src/pages/mutations.tsx +++ b/website/src/pages/mutations.tsx @@ -21,10 +21,18 @@ import * as turf from "@turf/turf"; import { FlyToInterpolator } from "@deck.gl/core"; import { parse } from "path"; import { useQuery } from "react-query"; +import { GeoJsonLayer } from "@deck.gl/layers"; +import DeckGL from "@deck.gl/react"; const MutationsMap = dynamic(() => import("../components/Mutations/Map"), { ssr: false, }); +const MutationsMinimap = dynamic( + () => import("../components/Mutations/Minimap"), + { + ssr: false, + } +); const INITIAL_VIEW_STATE = { latitude: 46.8182, @@ -209,7 +217,11 @@ export default function Page() { >
{year1} - +
{year2} - +
+
+ +
); } - -const SAMPLE_HTML = ` - - - - - - - - -`;