import { StyleLike } from "ol/style/Style"; import { Style } from "ol/style"; import { Feature } from "ol"; import { Geometry } from "ol/geom"; import RenderFeature from "ol/render/Feature"; import { StyleContext } from "../context/LolOpenLayersMapContext"; import { LolOpenLayersLayerDef } from "./LolOpenLayersLayerDef"; import { IFeatureSource } from "../sourceDefinition/LolOpenLayersSourceDef"; /** * Function signature to generate a style dynamically * using `StyleContext` information */ export type StyleWithContext = ( feature: Feature | RenderFeature, resolution: number, styleContext: StyleContext | undefined ) => Style | Style[]; /** * Function signature to filter and/or alter features */ export type FeatureFilter = (features: IFeatureSource[]) => IFeatureSource[]; /** * Style type for highlights. Can either totally override the style (when a highlight layer is used) * or alter the passed `plainStyle` to implement a highlight. */ export type HighlightStyle = | (( plainStyle: Style | Style[], feature: Feature, resolution: number ) => Style | Style[]) | Style | Style[] | undefined; /** * Definition of a vector layer, inherited to VectorTileLayer * These layers have distinct features that we can manipulate. */ export interface LolOpenLayersVectorLayerDef extends LolOpenLayersLayerDef { /** Layer style. By using the `StyleWithContext` a style gets passed a `StyleContext` * allowing the styling to be controlled from within the context. * This can style labels and features when no labelStyle is provided (then labels can't be separately decluttered) */ style: Style | StyleLike | StyleWithContext; /** * Label style. When provided, allow labels to be styles separately from the feature. * This will cause a label layer (named '_labels') to be created above out feature * layer. `declutterLabels` can then be used to separatly declutter. */ labelStyle?: Style | StyleLike | Style[] | StyleWithContext | undefined; /** * Highlight style. Will be used when a selected feature is to be highlighted. * Is passed the `plainStyle` for the feature. */ highlightStyle?: HighlightStyle; /** Set this true if the layer is to be included in initial zoom / zoom to survey. Default false. */ inInitialZoom?: boolean; /** Set this to true to use a layer to highlight selected features. Alternative is to use a highlight style */ highlightInLayer?: boolean; /** * Declutter images and text * Defaults to false * Decluttering is applied to all image and text styles of all Vector and VectorTile layers that have set this to true * see (https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html) **/ declutter?: boolean; /** * Declutter labels * Defaults to false * Separately declutter the labels layer. Will only work when `highlightInLayer` is set **/ declutterLabels?: boolean; /** * Allow a feature to be selected (at component level). * Defaults to false * NOTE: landonline-survey CaptureMap currently does its own selection for objects selected on the panel */ togglable?: boolean; /** * Filter and/or modify features on load * NOTE: experimental, no mock support */ featureFilter?: FeatureFilter; /** * Allows a feature to be selected by clicking the label * (applies when there is a `labelStyle` putting the label in its own layer) * By default, clicking the label does not select the feature in this case. */ selectableLabel?: boolean; /** * Clips features to bounding box before render. * This moves the label to the centre of the line, etc. * NOTE: experimental, not tested at mock level but has a story. */ clipFeatures?: boolean; }