PointInput

Form input for drawing a GeoJSON.Point. Renders a Geoman toolbar with the marker tool active.

Installation

pnpm dlx shadcn@latest add @shadmin/point-input

Usage

import { PointInput } from "@/components/leaflet";
 
<Create>
  <SimpleForm>
    <PointInput
      source="geom"
      label="Pick a point"
      defaultCenter={[48.85, 2.35]}
    />
  </SimpleForm>
</Create>;

Drawn geometry is persisted as a GeoJSON.Point to the form field source via React Hook Form.

Props

PropRequiredTypeDefaultDescription
sourceRequiredstring-RHF field name to write the geometry to.
zoomOptionalnumber13Initial zoom level.
defaultCenterOptional[number, number][0, 0]Initial map center [lat, lng].
heightOptionalnumber | string300Height of the map container.
tileUrlOptionalstringOpenStreetMap tile URLTile layer URL template.
attributionOptionalstringOSM attributionTile attribution string.
pathOptionsOptionalL.PathOptions-Vector styling for the drawn layer.
snappableOptionalbooleantrueEnable Geoman snap-to-vertex.
snapDistanceOptionalnumber20Snap radius in pixels.
labelOptionalReactNode-Label rendered above the map.
helperTextOptionalReactNode-Helper text rendered below the map.
disabledOptionalbooleanfalseDisable editing.
validateOptional(v) => string | undefined-RHF-compatible validator(s).