← คอมโพเนนต์ทั้งหมด
ไทม์ไลน์
เล่น เลื่อน และเร่งความเร็วเหตุการณ์ตามเวลา พร้อมเครื่องหมายและกราฟเส้นย่อ
ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ MapScale
ติดตั้ง
npx shadcn@latest add https://mapscale.io/r/timeline.jsonวิธีใช้
import { Timeline } from "@/components/mapscale/timeline"
const [value, setValue] = useState(start)
const [playing, setPlaying] = useState(false)
<Timeline
start={start}
end={end}
value={value}
onChange={setValue}
playing={playing}
onPlayingChange={setPlaying}
events={[{ time: start + 3 * DAY, label: "First report", color: "#e11d48" }]}
/>พร็อพ
| พร็อพ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| start | number | - | First timestamp (ms). |
| end | number | - | Last timestamp (ms). |
| value | number | - | Current timestamp (ms). Controlled. |
| onChange | (value) => void | - | Called while scrubbing or playing. |
| playing | boolean | - | Whether playback is running. Controlled. |
| onPlayingChange | (playing) => void | - | Called when play, pause or the end of the range is reached. |
| speed | 1 | 2 | 5 | 10 | 1 | Playback multiplier: 1, 2, 5 or 10. |
| events | TimelineEvent[] | - | Ticks on the scrubber: { time, label, color }. |
| series | TimelineSeries[] | - | Optional sparklines: { label, points: [t, v][] }. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ