import type { MapApi } from "../core/types"; import type { LayerHandle } from "./types"; /** * Options for the `useFitToContent` hook. */ export type FitToContentOptions = Readonly<{ /** Skip the automatic initial fit entirely. Default: false */ disabled?: boolean; /** Padding in pixels around the fitted bounds. Default: 50 */ padding?: number; /** Maximum zoom level after fitting. Default: 18 */ maxZoom?: number; /** Timeout in ms before fitting with whatever data is available. Default: 10000 */ timeout?: number; }>; /** * Return type of the `useFitToContent` hook. */ export type FitToContentResult = Readonly<{ /** True once the initial fit has been performed (or skipped due to empty bounds). */ hasFitted: boolean; /** True while waiting for participating layers to load before the initial fit. */ isWaiting: boolean; /** Manually trigger a fit-to-content. Animates. Only includes `fitParticipation: "all"` layers. */ fitNow: () => void; }>; /** * `useFitToContent` -- orchestrates a one-time viewport fit once all * participating layers have loaded their initial data. * * Only layers with `fitParticipation !== "none"` are waited on and included * in the initial fit. `fitNow()` only includes `fitParticipation: "all"` layers. * * A configurable timeout (default 10s) ensures the map fits to whatever * data is available if some layers are slow. * * When using this hook alongside an adapter's `initialViewport`, note that the * initial viewport serves as a loading-state viewport and will be overridden * once layer data arrives and the fit is performed. * * @example * ```tsx * const markers = useMarkers({ id: "fleet", ..., loading: isLoading }); * const shapes = useShapes({ id: "zones", ..., fitParticipation: "none" }); * const layers = useLayers(api, [markers, shapes]); * * const { hasFitted, isWaiting, fitNow } = useFitToContent(api, layers.handles); * * return ( * * * {hasFitted ? : null} * * ); * ``` */ export declare const useFitToContent: (api: MapApi, handles: ReadonlyArray, options?: FitToContentOptions) => FitToContentResult;