From 5fe51261233cf375f0c01b5142dcff24535cd5ef Mon Sep 17 00:00:00 2001 From: Beatrice Mkumbo Date: Fri, 22 Sep 2023 09:28:43 +0300 Subject: [PATCH] feat(web): Add layers using wms and mvt (#694) --- .../Editor/DataSourceManager/Asset/index.tsx | 6 +- .../DataSourceManager/DelimitedText/index.tsx | 6 +- .../DataSourceManager/ThreeDTiles/index.tsx | 6 +- .../DataSourceManager/VectorTiles/index.tsx | 124 ++++++++++++++++++ .../DataSourceManager/WmsTiles/index.tsx | 124 ++++++++++++++++++ .../Editor/DataSourceManager/hooks.ts | 46 +++++++ .../Editor/DataSourceManager/index.tsx | 12 ++ .../Editor/DataSourceManager/utils.tsx | 25 +++- web/src/services/i18n/translations/en.yml | 5 +- web/src/services/i18n/translations/ja.yml | 5 +- 10 files changed, 347 insertions(+), 12 deletions(-) create mode 100644 web/src/beta/features/Editor/DataSourceManager/VectorTiles/index.tsx create mode 100644 web/src/beta/features/Editor/DataSourceManager/WmsTiles/index.tsx create mode 100644 web/src/beta/features/Editor/DataSourceManager/hooks.ts diff --git a/web/src/beta/features/Editor/DataSourceManager/Asset/index.tsx b/web/src/beta/features/Editor/DataSourceManager/Asset/index.tsx index c832c7a113..ee2b792d2c 100644 --- a/web/src/beta/features/Editor/DataSourceManager/Asset/index.tsx +++ b/web/src/beta/features/Editor/DataSourceManager/Asset/index.tsx @@ -9,7 +9,7 @@ import { useT } from "@reearth/services/i18n"; import { DataProps } from ".."; import { - ColJustiftBetween, + ColJustifyBetween, AssetWrapper, InputGroup, Input, @@ -88,7 +88,7 @@ const Asset: React.FC = ({ sceneId, onSubmit, onClose }) => { }; return ( - + = ({ sceneId, onSubmit, onClose }) => { disabled={(sourceType === "url" || sourceType === "value") && !value} /> - + ); }; diff --git a/web/src/beta/features/Editor/DataSourceManager/DelimitedText/index.tsx b/web/src/beta/features/Editor/DataSourceManager/DelimitedText/index.tsx index 4b0c816d4a..8bc3ef88ee 100644 --- a/web/src/beta/features/Editor/DataSourceManager/DelimitedText/index.tsx +++ b/web/src/beta/features/Editor/DataSourceManager/DelimitedText/index.tsx @@ -8,7 +8,7 @@ import { useT } from "@reearth/services/i18n"; import { DataProps } from ".."; import { - ColJustiftBetween, + ColJustifyBetween, AssetWrapper, InputGroup, Input, @@ -57,7 +57,7 @@ const DelimitedText: React.FC = ({ sceneId, onSubmit, onClose }) => { }; return ( - + = ({ sceneId, onSubmit, onClose }) => { disabled={(sourceType === "url" || sourceType === "value") && !value} /> - + ); }; diff --git a/web/src/beta/features/Editor/DataSourceManager/ThreeDTiles/index.tsx b/web/src/beta/features/Editor/DataSourceManager/ThreeDTiles/index.tsx index 331da788dc..e9c1e5d4cc 100644 --- a/web/src/beta/features/Editor/DataSourceManager/ThreeDTiles/index.tsx +++ b/web/src/beta/features/Editor/DataSourceManager/ThreeDTiles/index.tsx @@ -4,7 +4,7 @@ import Button from "@reearth/beta/components/Button"; import generateRandomString from "@reearth/beta/utils/generate-random-string"; import { DataProps } from ".."; -import { ColJustiftBetween, AssetWrapper, InputGroup, Input, SubmitWrapper } from "../utils"; +import { ColJustifyBetween, AssetWrapper, InputGroup, Input, SubmitWrapper } from "../utils"; const ThreeDTiles: React.FC = ({ sceneId, onSubmit, onClose }) => { const [value, setValue] = React.useState(""); @@ -38,7 +38,7 @@ const ThreeDTiles: React.FC = ({ sceneId, onSubmit, onClose }) => { }; return ( - + = ({ sceneId, onSubmit, onClose }) => { disabled={!value} /> - + ); }; diff --git a/web/src/beta/features/Editor/DataSourceManager/VectorTiles/index.tsx b/web/src/beta/features/Editor/DataSourceManager/VectorTiles/index.tsx new file mode 100644 index 0000000000..6aea77fe40 --- /dev/null +++ b/web/src/beta/features/Editor/DataSourceManager/VectorTiles/index.tsx @@ -0,0 +1,124 @@ +import { FC } from "react"; + +import Button from "@reearth/beta/components/Button"; +import generateRandomString from "@reearth/beta/utils/generate-random-string"; +import { useT } from "@reearth/services/i18n"; + +import { DataProps } from ".."; +import useHooks from "../hooks"; +import { + AddLayerWrapper, + AssetWrapper, + ColJustifyBetween, + DeleteLayerIcon, + Input, + InputGroup, + LayerWrapper, + SubmitWrapper, +} from "../utils"; + +const VectorTiles: FC = ({ sceneId, onSubmit, onClose }) => { + const { + urlValue, + layerValue, + layerInput, + layers, + setUrlValue, + setLayerValue, + handleAddLayer, + handleDeleteLayer, + handleLayerInput, + } = useHooks(); + + const t = useT(); + + const handleSubmit = () => { + onSubmit({ + layerType: "simple", + sceneId, + title: generateRandomString(5), + visible: true, + config: { + data: { + url: urlValue !== "" ? urlValue : null, + type: "mvt", + layers: layers.length <= 1 ? layers[0] : layers, + }, + resource: { + clampToGround: true, + }, + marker: { + heightReference: "clamp", + }, + polygon: { + heightReference: "clamp", + }, + polyline: { + clampToGround: true, + }, + }, + }); + onClose(); + }; + + return ( + + + + setUrlValue(e.target.value)} + /> + + + {layers.map((layer: string, index: number) => ( + + + handleDeleteLayer(index)} /> + + ))} + {(!layers.length || layerInput) && ( + + setLayerValue(e.target.value)} + onKeyDown={handleAddLayer} + /> + + + )} + + +