← All components
Address search
Thai and English address autocomplete that flies the map to the result.
Previews run on MapScale's public Thailand archive.
Install
npx shadcn@latest add https://mapscale.io/r/address-autocomplete.jsonUsage
import { AddressAutocomplete } from "@/components/mapscale/address-autocomplete"
<Map lang="th">
<div className="absolute top-3 left-3 z-10 w-72">
<AddressAutocomplete onSelect={(place) => console.log(place.label, place.lngLat)} />
</div>
</Map>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| onSelect | (place) => void | - | Receives { id, label, lngLat, details } for the chosen place. |
| apiKey | string | NEXT_PUBLIC_MAPSCALE_KEY | Publishable key (pk_). Defaults to NEXT_PUBLIC_MAPSCALE_KEY. |
| lang | string | Map lang | Result language. Defaults to the surrounding Map. |
| flyTo | boolean | true | Fly the surrounding Map to the chosen place. |
| debounceMs | number | 200 | Delay before a search request is sent. |
Keys
Maps, autocomplete and place details use a publishable pk_ key that is safe in the browser. Routing and isochrones need a secret sk_ key, so they go through the proxy route your app serves.