import React from "react"; import { ViewStyle, StyleProp, Text, View } from "react-native"; import { MapMarkerClusterContext } from "./MapMarkerClusterContext"; import { withTheme } from "@draftbit/theme"; import type { ReadTheme } from "@draftbit/theme"; interface MapMarkerClusterViewProps { zoomOnPress?: boolean; onPress?: (latitude: number, longitude: number) => void; renderItem?: ({ markerCount }: { markerCount: number }) => JSX.Element; tracksViewChanges?: boolean; style?: StyleProp; } /** * Overrides the default cluster component that is rendered when a group of markers are clustered together * * Placed inside a MapMarkerCluster when manually creating clusters * OR inside a MapView when relying on automatic clustering based on distance */ const MapMarkerClusterView: React.FC = ({ renderItem, style, }) => { const { markerCount } = React.useContext(MapMarkerClusterContext); return ( {renderItem?.({ markerCount: markerCount || 0 })} ); }; export const DefaultMapMarkerClusterView = withTheme( ({ theme }: { theme: ReadTheme }) => { return ( ( {markerCount} )} /> ); } ); export default MapMarkerClusterView;