← คอมโพเนนต์ทั้งหมด

ค้นหาที่อยู่

ค้นหาที่อยู่ภาษาไทยและอังกฤษ แล้วบินไปยังผลลัพธ์บนแผนที่

ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ MapScale

ติดตั้ง

npx shadcn@latest add https://mapscale.io/r/address-autocomplete.json

วิธีใช้

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>

พร็อพ

พร็อพชนิดค่าเริ่มต้นคำอธิบาย
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.

คีย์

แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ