import type { MapOptions as OlMapBaseOptions } from "ol/Map"; import type OlView from "ol/View"; import type { ViewOptions as OlViewOptions } from "ol/View"; import type { Layer } from "../layers/unions"; /** * Configures an extent. * * Coordinates must be valid for the map's configured projection. * * @group Map Model */ export interface ExtentConfig { xMin: number; yMin: number; xMax: number; yMax: number; } /** * Configures a coordinate. * * Coordinates must be valid for the map's configured projection. * * @group Map Model */ export interface CoordinateConfig { x: number; y: number; z?: number; } /** * Configures the map's initial extent. * * @group Map Model */ export interface InitialExtentConfig { kind: "extent"; extent: ExtentConfig; } /** * Configures the map's initial position. * * @group Map Model */ export interface InitialPositionConfig { kind: "position"; center: CoordinateConfig; zoom: number; } /** * Configures the map's initial view. * * @group Map Model */ export type InitialViewConfig = InitialExtentConfig | InitialPositionConfig; /** * Advanced options during map construction. * * @group Map Model */ export interface OlMapOptions extends Omit { /** * Advanced options to control the view. * * We recommend using the `OlViewOptions` type. * * > Warning: When a fully constructed `OlView` instance is provided, some options * > of {@link MapConfig} (such as `initialView` or `projection`) cannot be applied anymore. */ view: OlView | OlViewOptions | Promise | undefined; } /** * Options supported during map construction. * * @group Map Model */ export interface MapConfig { /** * Configures the initial view. * This can be an extent, or a (center, zoom) value. */ initialView?: InitialViewConfig; /** * Configures a specific projection, e.g. `"EPSG:4326"`. * Defaults to `EPSG:3857`. * * To use custom projections, make sure that they are registered first: * * ```ts * import { registerProjections } from "@open-pioneer/map"; * * // Usually done at the top of the module. * // This will register the projection(s) in proj4's global registry. * registerProjections({ * "EPSG:31466": "+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +nadgrids=BETA2007.gsb +units=m +no_defs +type=crs", * // ... more projections * }); * * // later, use projection: "EPSG:31466" * ``` */ projection?: "EPSG:3857" | "EPSG:4326" | "EPSG:25832" | "EPSG:25833" | (string & {}); /** * Configures the layers of the map. * * **Layer order** * * Layers defined in this array are (by default) displayed in their listed order: * layers defined first are shown at the bottom, and layers defined at a later position * are shown _above_ their predecessors. * * Note: base layers are always shown below all operational layers. */ layers?: Layer[]; /** * Configures the base layers of the map. * * Base layers are always displayed below all operational layers. * Only one base layer can be active (visible) at a time. * * Note: Prefer this property over the `LayerConfig.isBaseLayer` property. */ baseLayers?: Layer[]; /** * Configures the topmost layers of the map. * * Topmost layers are always displayed above all operational layers and base layers. * The order of topmost layers is determined by their order in this array, with layers defined later being displayed above earlier ones. */ topmostLayers?: Layer[]; /** * Whether to show the default attribution control. * * The default value is `true`, unless `advanced` options are defined. * The default value changes to `false` if `advanced.controls` defined, mostly for backwards compatibility. * If `showDefaultAttributions` is set explicitly to `true` _or_ `false`, that value always has precedence. * * > NOTE: Disabling the default attribution control typically means that you must render the attributions yourself (see {@link MapModel.attributionItems}) * > to comply with the terms of service of your map services. */ showAttributions?: boolean; /** * Advanced OpenLayers configuration. * * Options in this object are passed to the OlMap's constructor. * Other properties defined in this configuration (e.g. {@link initialView}) * will be applied on top of these map options. * * > Warning: Not all properties here are supported. * > For example, you cannot set the `target` because the target is controlled by the ``. */ advanced?: Partial; }