base layer config

This commit is contained in:
Anton Tranelis 2025-07-01 16:45:23 +02:00
parent f3406d50c0
commit f9eba07c2f
4 changed files with 22 additions and 2 deletions

View File

@ -84,6 +84,8 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
defaultTheme={map.default_theme} defaultTheme={map.default_theme}
showZoomControl={map.show_zoom_control} showZoomControl={map.show_zoom_control}
expandLayerControl={map.expand_layer_control} expandLayerControl={map.expand_layer_control}
tileServerUrl={map.tile_server_url}
tileServerAttribution={map.tile_server_attribution}
> >
{layers && {layers &&
apis && apis &&

View File

@ -56,6 +56,8 @@ function UtopiaMap({
defaultTheme, defaultTheme,
donationWidget, donationWidget,
expandLayerControl, expandLayerControl,
tileServerUrl,
tileServerAttribution,
}: { }: {
/** height of the map (default '500px') */ /** height of the map (default '500px') */
height?: string height?: string
@ -85,6 +87,10 @@ function UtopiaMap({
donationWidget?: boolean donationWidget?: boolean
/** open layer control on map initialisation */ /** open layer control on map initialisation */
expandLayerControl?: boolean expandLayerControl?: boolean
/** configure a custom tile server */
tileServerUrl?: string
/** configure a custom tile server attribution */
tileServerAttribution?: string
}) { }) {
return ( return (
<ContextWrapper> <ContextWrapper>
@ -104,6 +110,8 @@ function UtopiaMap({
showThemeControl={showThemeControl} showThemeControl={showThemeControl}
defaultTheme={defaultTheme} defaultTheme={defaultTheme}
expandLayerControl={expandLayerControl} expandLayerControl={expandLayerControl}
tileServerUrl={tileServerUrl}
tileServerAttribution={tileServerAttribution}
> >
{children} {children}
</UtopiaMapInner> </UtopiaMapInner>

View File

@ -55,6 +55,8 @@ export function UtopiaMapInner({
defaultTheme = '', defaultTheme = '',
donationWidget, donationWidget,
expandLayerControl, expandLayerControl,
tileServerUrl,
tileServerAttribution,
}: { }: {
children?: React.ReactNode children?: React.ReactNode
geo?: GeoJsonObject geo?: GeoJsonObject
@ -65,6 +67,8 @@ export function UtopiaMapInner({
showThemeControl?: boolean showThemeControl?: boolean
defaultTheme?: string defaultTheme?: string
expandLayerControl?: boolean expandLayerControl?: boolean
tileServerUrl?: string
tileServerAttribution?: string
}) { }) {
const selectNewItemPosition = useSelectPosition() const selectNewItemPosition = useSelectPosition()
const setSelectNewItemPosition = useSetSelectPosition() const setSelectNewItemPosition = useSetSelectPosition()
@ -277,8 +281,12 @@ export function UtopiaMapInner({
</Control> </Control>
<TileLayer <TileLayer
maxZoom={19} maxZoom={19}
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' tileSize={256}
url='https://tile.osmand.net/hd/{z}/{x}/{y}.png' attribution={
tileServerAttribution ??
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
url={tileServerUrl ?? 'https://tile.osmand.net/hd/{z}/{x}/{y}.png'}
/> />
<MarkerClusterGroup <MarkerClusterGroup
ref={(r) => setClusterRef(r as any)} ref={(r) => setClusterRef(r as any)}

View File

@ -18,4 +18,6 @@ export interface UtopiaMapProps {
donationWidget?: boolean donationWidget?: boolean
defaultTheme?: string defaultTheme?: string
expandLayerControl?: boolean expandLayerControl?: boolean
tile_server_url?: string
tile_server_attribution?: string
} }