← 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.json

Usage

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

PropTypeDefaultDescription
onSelect(place) => void-Receives { id, label, lngLat, details } for the chosen place.
apiKeystringNEXT_PUBLIC_MAPSCALE_KEYPublishable key (pk_). Defaults to NEXT_PUBLIC_MAPSCALE_KEY.
langstringMap langResult language. Defaults to the surrounding Map.
flyTobooleantrueFly the surrounding Map to the chosen place.
debounceMsnumber200Delay 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.