GeoJSONField

Polymorphic read-only Leaflet field that renders any GeoJSON geometry (Point, LineString, Polygon, Multi\*, or GeometryCollection) stored at a record field.

Installation

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

Usage

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

Dispatches by geometry.type internally via L.GeoJSON, which handles every GeoJSON geometry kind.

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-Record field holding any GeoJSON geometry.
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-Vector styling for every shape.
pathOptionsByTypeOptionalPartial<Record<GeoJSON.Geometry["type"], L.PathOptions>>-Reserved for v2. v1 falls back to pathOptions.
markerIconOptionalL.Icon | L.DivIconshared MarkerIconIcon 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.