← คอมโพเนนต์ทั้งหมด
มาร์กเกอร์และคลัสเตอร์
ใช้เนื้อหา React เป็นมาร์กเกอร์ และเลเยอร์คลัสเตอร์ที่ใช้สีจากธีมของคุณ
ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ MapScale
ติดตั้ง
npx shadcn@latest add https://mapscale.io/r/map-marker.jsonวิธีใช้
import { MapMarker, MapMarkerCluster } from "@/components/mapscale/map-marker"
<Map>
<MapMarker lngLat={[100.5018, 13.7563]} draggable onDragEnd={console.log} />
<MapMarkerCluster data={points} />
</Map>พร็อพ
| พร็อพ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| lngLat | [number, number] | - | Marker position as [lng, lat]. |
| draggable | boolean | false | Lets people drag the marker; read the result in onDragEnd. |
| anchor | string | "center" | Which part of the marker sits on the coordinate. |
| onClick | (event) => void | - | Click handler for the marker element. |
| children | ReactNode | - | React content rendered into the marker through a portal. |
| data | FeatureCollection<Point> | - | MapMarkerCluster: a GeoJSON FeatureCollection of points. |
| renderMarker | (feature) => ReactNode | - | MapMarkerCluster: render an HTML marker for each unclustered point. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ