/** * Feature labels, with collision avoidance. * * Label placement is where chart-library maps visibly lose to Mapbox and ArcGIS * today, so even the phase-1 version does the * things that matter: * * - **Priority ordering.** Larger and higher-valued features win, so dropping * labels degrades gracefully instead of arbitrarily. * - **Axis-aligned collision** against already-placed labels. * - **Area gating.** A label wider than its feature is noise. * - **Halo by default** via `paint-order`, so text stays readable on any fill. * * Labels are drawn in the screen-space overlay, not the world group: text must * not scale with the camera. They are re-laid-out on camera change, which is * cheap because the candidate set is small and pre-sorted. * * @module components/Labels */ import type { SvgRenderer } from '../renderers/SvgRenderer'; import type { Viewport } from '../geo/Viewport'; import type { Anchor, DataLabelOptions, NormalizedFeature, WorldPoint } from '../types'; export interface LabelCandidate { text: string; /** Anchor in world space. */ world: WorldPoint; /** Higher wins when labels collide. */ priority: number; /** Approximate world-space area, in square pixels. */ featureArea: number; color?: string; key?: string; } export declare class Labels { readonly renderer: SvgRenderer; readonly viewport: Viewport; /** Re-pointed at the live config on every draw; see `_syncComponentOptions`. */ options: DataLabelOptions; candidates: LabelCandidate[]; group: SVGGElement | null; placedCount: number; droppedCount: number; constructor({ renderer, viewport, options, }: { renderer: SvgRenderer; viewport: Viewport; options: DataLabelOptions; }); setCandidates(candidates: LabelCandidate[]): void; /** * Lay out and draw. Called after every render and camera change. * * @param reserved Screen-space boxes already occupied, currently the * annotation chips. A generated label yields to an annotation rather than * the other way round: the annotation was placed deliberately and the label * was produced by a rule, so the rule is the one that should give way. */ layout(reserved?: readonly Box[]): void; destroy(): void; } /** An axis-aligned screen-space box, the unit of label collision. */ export interface Box { x0: number; y0: number; x1: number; y1: number; } /** * Label anchor for a feature, in world space. * * Uses the projected path centroid, then falls back to the bounding-box centre. * A proper pole-of-inaccessibility anchor (`polylabel`) is a phase-2 item: it * matters for concave shapes such as Florida or Chile where the centroid lands * offshore, and it is not worth the dependency until the label engine is doing * leader lines too. * */ export declare function labelAnchor(viewport: Viewport, feature: NormalizedFeature): Anchor | null; //# sourceMappingURL=Labels.d.ts.map