GeoJSONInput
Polymorphic form input for drawing any GeoJSON geometry. Renders a Geoman toolbar with one button per allowed shape kind. Defaults to allowing Point, LineString, and Polygon.
Installation
pnpm dlx shadcn@latest add @shadmin/geojson-inputUsage
import { GeoJsonInput } from "@/components/leaflet";
<Create>
<SimpleForm>
<GeoJsonInput
source="geom"
shapes={["Polygon"]}
label="Polygons only"
defaultCenter={[48.85, 2.35]}
/>
</SimpleForm>
</Create>;When collection is true, persists as a GeometryCollection of every shape on the map; otherwise keeps only the most recently drawn shape.
Props
| Prop | Required | Type | Default | Description |
|---|---|---|---|---|
source | Required | string | - | RHF field to write the geometry to. |
shapes | Optional | ShapeKind[] | ["Point","LineString","Polygon"] | Allowed GeoJSON shape kinds. Each maps to a Geoman draw button; duplicate Geoman targets are deduped. |
collection | Optional | boolean | false | When true, writes a GeometryCollection; otherwise keeps the most recent shape. |
zoom | Optional | number | 13 | Initial zoom level. |
defaultCenter | Optional | [number, number] | [0, 0] | Initial map center [lat, lng]. |
height | Optional | number | string | 300 | Height of the map container. |
tileUrl | Optional | string | OpenStreetMap tile URL | Tile layer URL template. |
attribution | Optional | string | OSM attribution | Tile attribution string. |
pathOptions | Optional | L.PathOptions | - | Vector styling for drawn shapes. |
snappable | Optional | boolean | true | Enable Geoman snap-to-vertex. |
snapDistance | Optional | number | 20 | Snap radius in pixels. |
label | Optional | ReactNode | - | Label rendered above the map. |
helperText | Optional | ReactNode | - | Helper text rendered below the map. |
disabled | Optional | boolean | false | Disable editing. |
validate | Optional | (v) => string | undefined | - | RHF-compatible validator(s). |