import { Overlay as OlOverlay } from "ol"; import { Coordinate } from "ol/coordinate"; import { Options } from "ol/Overlay"; import { ReactNode } from "react"; import { InternalConstructorTag } from "../utils/InternalConstructorTag"; import { MapModel } from "./MapModel"; export declare const REGISTER_OVERLAY: unique symbol; export declare const UNREGISTER_OVERLAY: unique symbol; /** * Manages active overlays on the map. * * @group Map Model */ export declare class Overlays { #private; constructor(map: MapModel); [REGISTER_OVERLAY](overlay: Overlay): void; [UNREGISTER_OVERLAY](overlay: Overlay): void; /** * Add new overlay to the map. Returns the newly created overlay instance. */ add(options: OverlayOptions): Overlay; /** * Returns the list of all current overlays. */ getAll(): Overlay[]; /** * Destroys all overlays. */ clear(): void; } /** * Options that define the initial state of an overlay. * * @group Map Model */ export interface OverlayOptions { /** * Optional, readonly tag that helps identifying the overlay instance. */ tag?: string; /** * Displayed content of the overlay. * * @see {@link Overlay.setContent}. */ content?: ReactNode; /** * CSS classes of the HTML element that wraps the overlay's content. */ className?: string; /** * Role of the HTML element that wraps the overlay's content. */ ariaRole?: string; /** * Configures the position of the overlay. * The overlay is not rendered if position is `undefined` (the default). * * See {@link OverlayPosition} for all supported position options. * * The following shorthands are available: * - A plain `Coordinate` array can be used to specify a static coordinate on the map. * - `undefined` hides the overlay. * - `"follow-pointer"` can be used as a shorthand to follow the user's cursor. * * @see {@link Overlay.setPosition} to reconfigure the position. * @see {@link Overlay.currentCoordinate} to retrieve the actual position on the map. */ position?: Coordinate | "follow-pointer" | OverlayPosition; /** * Positioning of an overlay relative to its coordinates on the map. * * @see {@link Overlay.setPositioning} */ positioning?: OverlayPositioning; /** * Offsets in _pixels_ relative to the overlay`s coordinates on the map. * The first element in the array is the horizontal offset. * * @see {@link Overlay.setOffset} */ offset?: number[]; /** * Determines if event propagation to the map viewport should be stopped. * * By default `stopEvent` is `true`. */ stopEvent?: boolean; /** * Raw OpenLayers overlay properties. `OlOverlayOptions` override corresponding `OverlayProperties`, except for id and element. * * **warning** Using OpenLayers options can create inconsistencies that lead to errors. * The OpenLayers API can change with updates of OpenLayers. */ advanced?: OlOverlayOptions; } /** * The configured position of an overlay. * * @group Map Model */ export type OverlayPosition = /** Explicit (static) coordinates on the map. */ OverlayPositionCoordinate /** Update coordinates based on pointer movements on the map, useful for tooltips. */ | OverlayPositionFollowPointer; /** * Automatically positions the overlay on the mouse cursor's coordinates. * * This can be used, for example, to implement tooltips for map interactions. * * @group Map Model */ export interface OverlayPositionFollowPointer { kind: "follow-pointer"; /** * The initial coordinates. * * Use `undefined` (the default) to hide until the first mouse event on the map. */ initial?: Coordinate; } /** * Places the overlay at the given coordinates. * * @group Map Model */ export interface OverlayPositionCoordinate { kind: "coordinate"; /** * The explicit coordinates of the overlay on the map. * * Using `undefined` hides the overlay. */ coordinate?: Coordinate; } /** * Positioning of an overlay relative to its coordinates on the map. * * @group Map Model */ export type OverlayPositioning = "bottom-left" | "bottom-center" | "bottom-right" | "center-left" | "center-center" | "center-right" | "top-left" | "top-center" | "top-right"; /** @group Map Model */ export interface OlOverlayOptions extends Omit, "id" | "element"> { } /** * An overlay is an UI element that is displayed over the map. * * Overlays are tied to coordinates on the map and not to a position on the screen. * The overlay renders a react node at the specified coordinates. * * @group Map Model */ export declare class Overlay { #private; /** * Unique, readonly id of the overlay. * * Automatically assigned when the overlay is created. Use the `tag` property for custom identifiers. */ readonly id: string; /** * Optional, readonly tag that helps identifying the overlay instance. */ readonly tag: string | undefined; /** * Raw, corresponding OpenLayers overlay object. * * **warning** Manipulation of the OpenLayers object can create inconsistencies that lead to errors. The OpenLayers API can change with updates of OpenLayers. * * @see https://openlayers.org/en/latest/apidoc/module-ol_Overlay-Overlay.html */ readonly olOverlay: OlOverlay; constructor(internalTag: InternalConstructorTag, options: OverlayOptions, parent: Overlays); /** * Destroys the overlay and removes it from the map. * An overlay that is destroyed cannot be added to the map again. */ destroy(): void; /** * Indicates if the overlay instance has been destroyed. */ get isDestroyed(): boolean; /** * Current coordinates of the overlay on the map. * * The coordinates on the map are configured via {@link OverlayOptions.position} or {@link setPosition}. * * - If configured with static coordinates (i.e. `position.kind === "coordinate"`), this is * the same as `position.coordinate`. * - If configured with `"follow-pointer"` position, this is the result of the user's pointer movements. */ get currentCoordinate(): Coordinate | undefined; /** * The content of the overlay that is currently rendered. */ get content(): ReactNode; /** * The HTML element that that wraps the overlay's content. */ get element(): HTMLElement; /** * Offset in _pixels_ relative to the overlay`s coordinates. * * The first element in the array is the horizontal offset. */ get offset(): number[]; /** * The configured position of the overlay on the map. * * See also {@link currentCoordinate} to get the coordinate * that are the result of this configuration. * * > NOTE: The return value of the getter may not be the same * > as the input to the setter (or constructor) due to normalization. */ get position(): OverlayPosition; /** * Positioning of an overlay relative to its coordinates on the map. */ get positioning(): OverlayPositioning; /** * Set new content that is rendered on the overlay. */ setContent(content: ReactNode): void; /** * Set the position of the overlay. * * This controls the coordinates of the map. * The overlay is not rendered if the coordinates are `undefined`. * * See also {@link currentCoordinate} to get the coordinates * that are the result of this configuration. * * @see {@link OverlayPosition} */ setPosition(position: OverlayOptions["position"]): void; /** * Set offset in _pixels_ relative to the overlay`s coordinates on the map. * The first element in the array is the horizontal offset. */ setOffset(offset: number[]): void; /** * Set positioning of an overlay relative to its coordinates on the map. */ setPositioning(positioning: OverlayPositioning): void; }