Helper class for the OpenLayers map.

Constructors

Methods

  • Converts a given OpenLayers map to an inkmap spec. Only returns options which can be derived from a map (center, scale, projection, layers).

    Parameters

    • olMap: Map

      The ol map.

    Returns Promise<{
        center: Coordinate;
        layers: any[];
        projection: string;
        scale: undefined | number;
    }>

    Promise of the inmkap print spec.

  • Returns all layers of a collection. Even the hidden ones.

    Parameters

    • collection: Map | LayerGroup

      The collection to get the layers from. This can be an ol.layer.Group or an ol.Map.

    • Optional filter: ((olLayer) => boolean) = ...

      A filter function that receives the layer. If it returns true it will be included in the returned layers.

        • (olLayer): boolean
        • Parameters

          • olLayer: BaseLayer

          Returns boolean

    Returns BaseLayer[]

    An array of all Layers.

  • Returns all interactions by the given name of a map.

    Parameters

    • map: Map

      The map to use for lookup.

    • name: string

      The name of the interaction to look for.

    Returns Interaction[]

    The list of result interactions.

  • Returns the layer from the provided map by the given feature.

    Parameters

    • map: Map

      The map to use for lookup.

    • feature: Feature<Geometry>

      The feature to get the layer by.

    • namespaces: string[]

      list of supported GeoServer namespaces.

    Returns undefined | BaseLayer

    The result layer or undefined if the layer could not be found.

  • Returns the layer from the provided map by the given name.

    Parameters

    • map: Map

      The map to use for lookup.

    • name: string

      The name to get the layer by.

    Returns BaseLayer

    The result layer or undefined if the layer could not be found.

  • Returns the layer from the provided map by the given name (parameter LAYERS).

    Parameters

    • map: Map

      The map to use for lookup.

    • name: string

      The name to get the layer by.

    Returns undefined | WmsLayer

    The result layer or undefined if the layer could not be found.

  • Get a layer by its key (ol_uid).

    Parameters

    • map: Map

      The map to use for lookup.

    • olUid: string

    Returns undefined | BaseLayer

    The layer.

  • Get information about the LayerPosition in the tree.

    Parameters

    • layer: BaseLayer

      The layer to get the information.

    • groupLayerOrMap: Map | LayerGroup

      The groupLayer or map containing the layer.

    Returns LayerPositionInfo

    The groupLayer containing the layer and the position of the layer in the collection.

  • Returns all layers of the specified layer group recursively.

    Parameters

    • map: Map

      The map to use for lookup.

    • layerGroup: LayerGroup

      The group to flatten.

    Returns BaseLayer[]

    The (flattened) layers from the group

  • Returns the list of layers matching the given pair of properties.

    Parameters

    • map: Map

      The map to use for lookup.

    • key: string

      The property key.

    • value: any

      The property value.

    Returns BaseLayer[]

    The array of matching layers.

  • Get the getlegendGraphic url of a layer. Designed for geoserver. Currently supported Sources:

    • ol.source.TileWms (with url configured)
    • ol.source.ImageWms (with url configured)
    • ol.source.WMTS (with url configured)

    Parameters

    • layer: WmsLayer | WmtsLayer

      The layer that you want to have a legendUrl for.

    • extraParams: {
          [key: string]: string | number;
      } = {}
      • [key: string]: string | number

    Returns string

    The getLegendGraphicUrl.

  • Calculates the appropriate map resolution for a given scale in the given units.

    See: https://gis.stackexchange.com/questions/158435/ how-to-get-current-scale-in-openlayers-3

    Parameters

    • scale: string | number

      The input scale to calculate the appropriate resolution for.

    • units: Units

      The units to use for calculation (m or degrees).

    Returns undefined | number

    The calculated resolution.

    Method

  • Returns the appropriate scale for the given resolution and units.

    Parameters

    • resolution: string | number

      The resolutions to calculate the scale for.

    • units: Units

      The units the resolution is based on, typically either 'm' or 'degrees'.

    Returns undefined | number

    The appropriate scale.

    Method

  • Returns the appropriate zoom level for the given scale and units.

    Parameters

    • scale: number

      Map scale to get the zoom for.

    • resolutions: number[]

      Resolutions array.

    • units: Units = 'm'

      The units the resolutions are based on, typically either 'm' or 'degrees'. Default is 'm'.

    Returns number

    Determined zoom level for the given scale.

    Method

  • Checks if the given layer is visible for the given resolution.

    Parameters

    • layer: BaseLayer

      The layer.

    • resolution: number

      The resolution of the map

    Returns boolean

  • Checks whether the resolution of the passed map's view lies inside of the min- and max-resolution of the passed layer, e.g. whether the layer should be displayed at the current map view resolution.

    Parameters

    • Optional layer: BaseLayer

      The layer to check.

    • Optional map: Map

      The map to get the view resolution for comparison from.

    Returns boolean

    Whether the resolution of the passed map's view lies inside of the min- and max-resolution of the passed layer, e.g. whether the layer should be displayed at the current map view resolution. Will be false when no layer or no map is passed or if the view of the map is falsy or does not have a resolution (yet).

  • Rounds a scale number depending on its size.

    Parameters

    • scale: number

      The exact scale

    Returns number

    The roundedScale

  • Set visibility for layer having names (if in map)

    Parameters

    • olMap: Map

      The OpenLayers map.

    • layerNames: string[]

      An array of layer names (feature type names can also be used)

    • visible: boolean

      if layer should be visible or not

    Returns void

  • Fits the map's view to the extent of the passed features.

    Parameters

    • map: Map

      The map to get the view from.

    • features: Feature<Geometry>[]

      The features to zoom to.

    Returns void