layer control customizing

This commit is contained in:
Anton Tranelis 2025-05-22 19:33:26 +02:00
parent baafaa43b1
commit 1795c90a58
4 changed files with 10 additions and 5 deletions

View File

@ -5,8 +5,8 @@ import LayerSVG from '#assets/layer.svg'
import { useIsLayerVisible, useToggleVisibleLayer } from '#components/Map/hooks/useFilter'
import { useLayers } from '#components/Map/hooks/useLayers'
export function LayerControl() {
const [open, setOpen] = useState(false)
export function LayerControl({ expandLayerControl = false }: { expandLayerControl: boolean }) {
const [open, setOpen] = useState(expandLayerControl)
const layers = useLayers()

View File

@ -54,6 +54,7 @@ function UtopiaMap({
showThemeControl = false,
defaultTheme,
donationWidget,
expandLayerControl,
}: {
/** height of the map (default '500px') */
height?: string
@ -79,6 +80,8 @@ function UtopiaMap({
defaultTheme?: string
/** ask to donate to the Utopia Project OpenCollective campaign (default false) */
donationWidget?: boolean
/** open layer control on map initialisation */
expandLayerControl?: boolean
}) {
return (
<ContextWrapper>
@ -97,6 +100,7 @@ function UtopiaMap({
donationWidget={donationWidget}
showThemeControl={showThemeControl}
defaultTheme={defaultTheme}
expandLayerControl={expandLayerControl}
>
{children}
</UtopiaMapInner>

View File

@ -22,9 +22,7 @@ import {
useAddVisibleLayer,
useFilterTags,
useResetFilterTags,
useResetVisibleLayers,
useToggleVisibleLayer,
useVisibleLayer,
} from './hooks/useFilter'
import { useLayers } from './hooks/useLayers'
import { useLeafletRefs } from './hooks/useLeafletRefs'
@ -56,6 +54,7 @@ export function UtopiaMapInner({
showThemeControl = false,
defaultTheme = '',
donationWidget,
expandLayerControl,
}: {
children?: React.ReactNode
geo?: GeoJsonObject
@ -65,6 +64,7 @@ export function UtopiaMapInner({
donationWidget?: boolean
showThemeControl?: boolean
defaultTheme?: string
expandLayerControl?: boolean
}) {
const selectNewItemPosition = useSelectPosition()
const setSelectNewItemPosition = useSetSelectPosition()
@ -272,7 +272,7 @@ export function UtopiaMapInner({
</Control>
<Control position='bottomLeft' zIndex='999' absolute>
{showFilterControl && <FilterControl />}
{showLayerControl && <LayerControl />}
{showLayerControl && <LayerControl expandLayerControl={expandLayerControl ?? false} />}
{showGratitudeControl && <GratitudeControl />}
</Control>
<TileLayer

View File

@ -16,4 +16,5 @@ export interface UtopiaMapProps {
infoText?: string
donationWidget?: boolean
defaultTheme?: string
expandLayerControl?: boolean
}