← All components
Marker and cluster
React content as markers, plus a clustered GeoJSON layer coloured from your theme tokens.
Previews run on MapScale's public Thailand archive.
Install
npx shadcn@latest add https://mapscale.io/r/map-marker.jsonUsage
import { MapMarker, MapMarkerCluster } from "@/components/mapscale/map-marker"
<Map>
<MapMarker lngLat={[100.5018, 13.7563]} draggable onDragEnd={console.log} />
<MapMarkerCluster data={points} />
</Map>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| 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. |
Keys
Maps, autocomplete and place details use a publishable pk_ key that is safe in the browser. Routing and isochrones need a secret sk_ key, so they go through the proxy route your app serves.