MapWithSearch

A composite map input pairing a draggable Leaflet marker with an address-search combobox, kept in two-way sync.

Installation

pnpm dlx shadcn@latest add @shadmin/map-with-search
  • Selecting a search result updates lat/lng/address and recenters the marker.
  • Dragging the marker triggers a reverse geocode that updates the address field.

Must be rendered inside a React Hook Form context (e.g. <SimpleForm>).

Usage

import { MapWithSearch } from "@/components/leaflet";
 
<SimpleForm>
  <MapWithSearch
    latSource="lat"
    lngSource="lng"
    addressSource="address"
    height={400}
  />
</SimpleForm>;

Props

PropRequiredTypeDefaultDescription
latSourceRequiredstring-RHF field name for latitude.
lngSourceRequiredstring-RHF field name for longitude.
addressSourceRequiredstring-RHF field name for the human-readable address (display name).
heightOptionalnumber | string400Height of the map container.
defaultZoomOptionalnumber13Initial zoom level.