Skip to content
Sign upPro
Apps SDKLocation pickerMenu

Location picker (Pro)

ProIncluded in $99

Set a pickup or delivery point the way a ride app does: the pin stays still and the map moves under it, snapping to the spots a car can actually stop.

ProDrag the map under the pin. Let go near a suggested spot and it snaps there.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/location-picker

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { LocationPicker } from "@/components/ui/chatcn/pro/location-picker"

<LocationPicker
  title="Pickup point"
  base={district}
  spots={[
    { id: "bakery", name: "Bakery corner", detail: "Step free", x: 240, y: 214 },
    { id: "rank", name: "Taxi rank", detail: "Covered", x: 304, y: 288 },
  ]}
  you={{ x: 178, y: 168, accuracy: 24 }}
  onConfirm={(point, spot) => book(spot ?? point)}
/>

The map is the same drawn MapBase the list map widget uses, so there are no tiles to load and it matches the theme. Drag it and the pin lifts with its shadow; let go and the map carries on with your flick on a spring, then the pin drops and the place is named below. Land within a thumb of a suggested spot and it snaps there. A tap moves the pin to the point tapped. Spot chips glide to each spot, the locate button goes to you, and the zoom buttons or a trackpad pinch zoom; ordinary scrolling stays with the page. Without a spot under the pin the name is the distance from the nearest one, or whatever describe returns, which is where a reverse geocoder goes. Set turns the pin green and holds it until Change.

Examples

States

ProA pickup already set, and a free pin with no suggested spots.

Props

PropTypeNotes
baseMapBaseWater, parks, streets, roads and labels in a 600 by 400 box
spotsLocationSpot[]{ id, name, detail?, x, y } the pin snaps to
you{ x, y, accuracy? }The user, with an accuracy ring in meters
defaultCenter, defaultZoomWhere it starts. Default the first spot
minZoom, maxZoomnumberDefault 1 and 3.5
metersPerUnitnumberFor distances. Default 1.5
describe(point, nearest) => { title, detail? }Name the point under the pin
onCenterChange, onConfirm(point, spot?) => voidWhen the pin rests, and when it is set
heightnumberMap height. Default 260
labelsPartial<LocationPickerLabels>Every string, for translation

Keyboard

KeyAction
Arrow keysMove the map; Shift moves further
+, -Zoom in or out
EnterSet the point

Accessibility

  • The map is a focusable group described as a map, with the keys in its description.
  • The place under the pin is a polite live region, so each stop is announced once.
  • Spot chips are toggle buttons; the one under the pin is pressed.

Motion

The map glides on a critically damped spring that keeps the release velocity. The pin lifts in 200 ms and drops with a small overshoot. Under reduced motion the map jumps and the location ring does not pulse.