← คอมโพเนนต์ทั้งหมด
คำอธิบายตามมุมมอง
คำอธิบายสดของสิ่งที่อยู่บนหน้าจอ พร้อมแถบเปอร์เซ็นต์และการกรองด้วยการคลิก
ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ MapScale
ติดตั้ง
npx shadcn@latest add https://mapscale.io/r/viewport-legend.jsonวิธีใช้
import { ViewportLegend } from "@/components/mapscale/viewport-legend"
<Map>
<GeoJSONLayer id="places" type="circle" data={places} />
<ViewportLegend
layerIds={["places"]}
property="kind"
categories={[
{ value: "cafe", label: "Cafe", color: "#c2410c" },
{ value: "park", label: "Park", color: "#15803d" },
]}
/>
</Map>พร็อพ
| พร็อพ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| layerIds | string[] | - | Map layers to query for features in view. |
| property | string | - | Feature property that holds the category value. |
| categories | LegendCategory[] | - | Rows of { value, label, color, icon }. |
| weightProperty | string | - | Sum this numeric property instead of counting features. |
| maxRows | number | 6 | Rows shown before the +N more link. |
| title | string | "In view" | Heading of the legend. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ