Skip to content

GebetaMap (React)

Import

jsx
import { GebetaMap } from '@gebeta/react';

Props

PropTypeRequiredDescription
auth{ accessToken: string, refreshToken: string }Yes*Service account credentials
apiKeystringYes*Legacy API key (deprecated)
center[number, number]NoInitial map center [lng, lat]
zoomnumberNoInitial zoom level
styleReact.CSSPropertiesNoContainer styles (passed to MapLibre)
classNamestringNoContainer class name
clustering{ enabled: boolean }NoEnable marker clustering
navigationControlbooleanNoShow zoom/compass controls
onLoad(map: { clustering: ClusteringManager | null }) => voidNoCalled when map style is loaded
onError(error: Error) => voidNoCalled on map error
childrenReactNodeNoChild components (rendered inside the map container)

*Either auth or apiKey is required.

Example

jsx
const auth = { accessToken, refreshToken };
const mapStyle = { width: '100%', height: '500px' };
const center = [38.7685, 9.0161];

<GebetaMap
  auth={auth}
  center={center}
  zoom={12}
  style={mapStyle}
  onLoad={({ clustering }) => {
    // clustering: ClusteringManager | null
  }}
/>;

Accessing clustering via hook

Use useClustering() inside a child component rather than via onLoad:

jsx
const clusteringOptions = { enabled: true };

<GebetaMap auth={auth} clustering={clusteringOptions}>
  <MarkersLayer />
</GebetaMap>;