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

เลเยอร์ GeoJSON

ประกาศแหล่งข้อมูลและเลเยอร์ใน JSX และคงอยู่แม้เปลี่ยนสไตล์

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

ติดตั้ง

npx shadcn@latest add https://mapscale.io/r/geojson-layer.json

วิธีใช้

import { GeoJSONLayer } from "@/components/mapscale/geojson-layer"

<Map>
	<GeoJSONLayer
		id="zones"
		type="fill"
		data={zones}
		paint={{ "fill-color": "#2563eb", "fill-opacity": 0.25 }}
	/>
</Map>

พร็อพ

พร็อพชนิดค่าเริ่มต้นคำอธิบาย
idstring-Used as both the source id and the layer id.
dataGeoJSON | string-GeoJSON object or URL. Updated in place when it changes.
typestring-fill, line, circle, symbol, heatmap or fill-extrusion.
paintobject{}MapLibre paint properties. Changes apply without re-adding the layer.
layoutobject{}MapLibre layout properties.
beforeIdstring-Insert the layer below this existing layer.

คีย์

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