FeatureCollectionField

Read-only Leaflet map that renders a GeoJSON.FeatureCollection stored at a record field. L.geoJSON renders the collection as a single multi-layer group — one layer per feature.

Installation

pnpm dlx shadcn@latest add @shadmin/feature-collection-field

Usage

import { FeatureCollectionField } from "@/components/leaflet";
 
<Show>
  <SimpleShowLayout>
    <FeatureCollectionField source="geom" />
  </SimpleShowLayout>
</Show>;

The source value is a GeoJSON.FeatureCollection ({ type: "FeatureCollection", features: [...] }). Renders an empty-state panel when the record value is missing.

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field holding the FeatureCollection.
zoomOptionalnumber13Initial zoom level.
defaultCenterOptional[number, number][0, 0]Fallback center [lat, lng].
heightOptionalnumber | string300Height of the map container.
tileUrlOptionalstringOpenStreetMap tile URLTile layer URL template.
attributionOptionalstringOSM attributionTile attribution string.
pathOptionsOptionalL.PathOptions{ color: "#3388ff" }Fill/stroke style options.
markerIconOptionalL.Icon | L.DivIconshared MarkerIconIcon used for Point geometries.
fitBoundsOptionalbooleantrueAuto-fit map view to the geometry.
emptyTextOptionalReactNode"No geometry…"Text shown when the value is missing.
testIdOptionalstring-data-testid for the map container.