← คอมโพเนนต์ทั้งหมด
ค้นหาที่อยู่
ค้นหาที่อยู่ภาษาไทยและอังกฤษ แล้วบินไปยังผลลัพธ์บนแผนที่
ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ 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. |
| 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. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ