FeatureField

Read-only Leaflet map that renders a GeoJSON.Feature stored at a record field. Leaflet's L.geoJSON accepts Features directly, so this is a thin wrapper around the shared shape-field shell.

Installation

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

Usage

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

The source value is a GeoJSON.Feature ({ type: "Feature", geometry, properties }). Renders an empty-state panel when the record value is missing.

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field holding the Feature.
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 when the geometry is a Point.
fitBoundsOptionalbooleantrueAuto-fit map view to the geometry.
emptyTextOptionalReactNode"No geometry…"Text shown when the value is missing.
testIdOptionalstring-data-testid for the map container.