From 59b462549331a8bcac0bcf0bbaff4371d09752e4 Mon Sep 17 00:00:00 2001 From: iandebruin98 Date: Thu, 7 Nov 2024 09:20:07 +0100 Subject: [PATCH] feat: Create admin fields to select map tiles layer variant --- .../pages/projects/[project]/settings/map.tsx | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/apps/admin-server/src/pages/projects/[project]/settings/map.tsx b/apps/admin-server/src/pages/projects/[project]/settings/map.tsx index 9a074a180..b58b3e036 100644 --- a/apps/admin-server/src/pages/projects/[project]/settings/map.tsx +++ b/apps/admin-server/src/pages/projects/[project]/settings/map.tsx @@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form'; import { Button } from '@/components/ui/button'; import { Form, - FormControl, + FormControl, FormDescription, FormField, FormItem, FormLabel, @@ -36,6 +36,8 @@ const formSchema = z.object({ maxZoom: z.string().optional(), minZoom: z.string().optional(), areaId: z.string().optional(), + tilesVariant: z.string().optional(), + customUrl: z.string().optional(), }); export default function ProjectSettingsMap() { @@ -51,6 +53,8 @@ export default function ProjectSettingsMap() { minZoom: data?.config?.map?.minZoom || '7', maxZoom: data?.config?.map?.maxZoom || '20', areaId: data?.config?.map?.areaId || '', + tilesVariant: data?.config?.map?.tilesVariant || 'nlmaps', + customUrl: data?.config?.map?.customUrl || '', } }, [data, areas] @@ -72,6 +76,8 @@ export default function ProjectSettingsMap() { areaId: values.areaId, minZoom: values.minZoom, maxZoom: values.maxZoom, + tilesVariant: values.tilesVariant, + customUrl: values.customUrl, }, }); if (project) { @@ -98,6 +104,14 @@ export default function ProjectSettingsMap() { } }, [ form.watch('minZoom'), form.watch('maxZoom') ] ); + const tileLayerOptions = [ + { value: 'nlmaps', label: 'Nederlandse Kaart' }, + { value: 'amaps', label: 'Amsterdam Kaart' }, + { value: 'openstreetmaps', label: 'OpenStreetMap' }, + { value: 'n3s', label: 'CartoDB Light' }, + { value: 'custom', label: 'Aangepaste Kaart' }, + ]; + return (
+ className="lg:w-2/3 grid grid-cols-1 lg:grid-cols-2 gap-x-4 gap-y-8"> + ( + + + Welke weergave van de kaart wil je gebruiken? + + + + + )} + /> + + {form.watch('tilesVariant') === 'custom' && ( + ( + + + Aangepaste URL + + {`Voer de URL in voor de aangepaste kaartweergave. Bijvoorbeeld: https://example.com/tiles/{z}/{x}/{y}.png`} + + + + + + )} + /> + )} +