PolygonField

Read-only Leaflet map that renders a GeoJSON.Polygon geometry stored at a record field.

Installation

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

Usage

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

Renders an empty-state panel when the record value is missing.

Props

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