← 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.json

Usage

import { MapMarker, MapMarkerCluster } from "@/components/mapscale/map-marker"

<Map>
	<MapMarker lngLat={[100.5018, 13.7563]} draggable onDragEnd={console.log} />
	<MapMarkerCluster data={points} />
</Map>

Props

PropTypeDefaultDescription
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.

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.