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

มาร์กเกอร์และคลัสเตอร์

ใช้เนื้อหา 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].
draggablebooleanfalseLets people drag the marker; read the result in onDragEnd.
anchorstring"center"Which part of the marker sits on the coordinate.
onClick(event) => void-Click handler for the marker element.
childrenReactNode-React content rendered into the marker through a portal.
dataFeatureCollection<Point>-MapMarkerCluster: a GeoJSON FeatureCollection of points.
renderMarker(feature) => ReactNode-MapMarkerCluster: render an HTML marker for each unclustered point.

คีย์

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