From f9eba07c2f85e6bc4fac4e68ebf5717a96d9293b Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 1 Jul 2025 16:45:23 +0200 Subject: [PATCH] base layer config --- frontend/src/pages/MapContainer.tsx | 2 ++ lib/src/Components/Map/UtopiaMap.tsx | 8 ++++++++ lib/src/Components/Map/UtopiaMapInner.tsx | 12 ++++++++++-- lib/src/types/UtopiaMapProps.d.ts | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/MapContainer.tsx b/frontend/src/pages/MapContainer.tsx index 14d96c71..fe3140a1 100644 --- a/frontend/src/pages/MapContainer.tsx +++ b/frontend/src/pages/MapContainer.tsx @@ -84,6 +84,8 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) { defaultTheme={map.default_theme} showZoomControl={map.show_zoom_control} expandLayerControl={map.expand_layer_control} + tileServerUrl={map.tile_server_url} + tileServerAttribution={map.tile_server_attribution} > {layers && apis && diff --git a/lib/src/Components/Map/UtopiaMap.tsx b/lib/src/Components/Map/UtopiaMap.tsx index da909e3b..3ca2a6e3 100644 --- a/lib/src/Components/Map/UtopiaMap.tsx +++ b/lib/src/Components/Map/UtopiaMap.tsx @@ -56,6 +56,8 @@ function UtopiaMap({ defaultTheme, donationWidget, expandLayerControl, + tileServerUrl, + tileServerAttribution, }: { /** height of the map (default '500px') */ height?: string @@ -85,6 +87,10 @@ function UtopiaMap({ donationWidget?: boolean /** open layer control on map initialisation */ expandLayerControl?: boolean + /** configure a custom tile server */ + tileServerUrl?: string + /** configure a custom tile server attribution */ + tileServerAttribution?: string }) { return ( @@ -104,6 +110,8 @@ function UtopiaMap({ showThemeControl={showThemeControl} defaultTheme={defaultTheme} expandLayerControl={expandLayerControl} + tileServerUrl={tileServerUrl} + tileServerAttribution={tileServerAttribution} > {children} diff --git a/lib/src/Components/Map/UtopiaMapInner.tsx b/lib/src/Components/Map/UtopiaMapInner.tsx index 0a5e04a7..fbd3a245 100644 --- a/lib/src/Components/Map/UtopiaMapInner.tsx +++ b/lib/src/Components/Map/UtopiaMapInner.tsx @@ -55,6 +55,8 @@ export function UtopiaMapInner({ defaultTheme = '', donationWidget, expandLayerControl, + tileServerUrl, + tileServerAttribution, }: { children?: React.ReactNode geo?: GeoJsonObject @@ -65,6 +67,8 @@ export function UtopiaMapInner({ showThemeControl?: boolean defaultTheme?: string expandLayerControl?: boolean + tileServerUrl?: string + tileServerAttribution?: string }) { const selectNewItemPosition = useSelectPosition() const setSelectNewItemPosition = useSetSelectPosition() @@ -277,8 +281,12 @@ export function UtopiaMapInner({ OpenStreetMap contributors' + } + url={tileServerUrl ?? 'https://tile.osmand.net/hd/{z}/{x}/{y}.png'} /> setClusterRef(r as any)} diff --git a/lib/src/types/UtopiaMapProps.d.ts b/lib/src/types/UtopiaMapProps.d.ts index 3d85374e..94a8986a 100644 --- a/lib/src/types/UtopiaMapProps.d.ts +++ b/lib/src/types/UtopiaMapProps.d.ts @@ -18,4 +18,6 @@ export interface UtopiaMapProps { donationWidget?: boolean defaultTheme?: string expandLayerControl?: boolean + tile_server_url?: string + tile_server_attribution?: string }