← คอมโพเนนต์ทั้งหมด
เลเยอร์ 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>พร็อพ
| พร็อพ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| id | string | - | Used as both the source id and the layer id. |
| data | GeoJSON | string | - | GeoJSON object or URL. Updated in place when it changes. |
| type | string | - | fill, line, circle, symbol, heatmap or fill-extrusion. |
| paint | object | {} | MapLibre paint properties. Changes apply without re-adding the layer. |
| layout | object | {} | MapLibre layout properties. |
| beforeId | string | - | Insert the layer below this existing layer. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ