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

คำอธิบายตามมุมมอง

คำอธิบายสดของสิ่งที่อยู่บนหน้าจอ พร้อมแถบเปอร์เซ็นต์และการกรองด้วยการคลิก

ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ 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>

พร็อพ

พร็อพชนิดค่าเริ่มต้นคำอธิบาย
layerIdsstring[]-Map layers to query for features in view.
propertystring-Feature property that holds the category value.
categoriesLegendCategory[]-Rows of { value, label, color, icon }.
weightPropertystring-Sum this numeric property instead of counting features.
maxRowsnumber6Rows shown before the +N more link.
titlestring"In view"Heading of the legend.

คีย์

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