# Class LayerHelper

#### Hierarchy

- LayerHelper

- Defined in src/map/LayerHelper.js:54

#####
Index

### Properties

$http_
$q_
tilesPreloadingLimit_

### Methods

copyProperties
createBasicGroup
createBasicVectorTilesLayer
createBasicWMSLayer
createBasicWMSLayerFromDataSource
createWMTSLayerFromCapabilitites
createWMTSLayerFromCapabilititesObj
fixResolution_
getFlatLayers
getFlatLayers_
getGroupFromMap
getLayerByNodeName
getQuerySourceIds
getWMSLegendURL
getWMTSLegendURL
isLayerVisible
refreshWMSLayer
setZIndexToFirstLevelChildren
updateWMSLayerState

## Properties

### $http_

$http_: IHttpService

- Defined in src/map/LayerHelper.js:63

### $q_

$q_: IQService

- Defined in src/map/LayerHelper.js:58

### tilesPreloadingLimit_

tilesPreloadingLimit_: number

The Tiles Preloading Limit value

- Defined in src/map/LayerHelper.js:70

## Methods

### copyProperties

- copyProperties(layerFrom, layerTo, opt_excludes?): void

- Copy each properties from a layer onto an other layer, with the option to exclude specific ones.

  #### Parameters

  - ##### layerFrom: Layer<Source, LayerRenderer<any>>

    The layer from which to copy the properties.

  - ##### layerTo: Layer<Source, LayerRenderer<any>>

    The layer onto which the properties are copied.

  - ##### `Optional` opt_excludes: string[]

    A list of properties that should not be copied.

  #### Returns void

  - Defined in src/map/LayerHelper.js:113

### createBasicGroup

- createBasicGroup(opt_layers?): LayerGroup

- Create and return an ol.layer.Group. You can pass a collection of layers to directly add them in the returned group.

  #### Parameters

  - ##### `Optional` opt_layers: Collection<BaseLayer>

    The layer to add to the returned Group.

  #### Returns LayerGroup

  Layer group.

  - Defined in src/map/LayerHelper.js:423

### createBasicVectorTilesLayer

- createBasicVectorTilesLayer(url, style, layername, projection, tileGrid, opt_minResolution?, opt_maxResolution?, opt_opacity?): any

- #### Parameters

  - ##### url: string

    URL template. Must include {x}, {y} or {-y}, and {z} placeholders. A {?-?} template pattern, for example subdomain{a-f}.domain.com, may be used instead. of defining each one separately in the urls option.

  - ##### style: string | Object

    a Mapbox Style object.

  - ##### layername: string

    the name of the url as identified in the style.

  - ##### projection: string

    The projection code.

  - ##### tileGrid: TileGrid

    The tile grid to define the source with.

  - ##### `Optional` opt_minResolution: number

    WMTS minimum resolution.

  - ##### `Optional` opt_maxResolution: number

    WMTS maximum resolution.

  - ##### `Optional` opt_opacity: number

    The opacity.

  #### Returns any

  Vector tile layer.

  - Defined in src/map/LayerHelper.js:383

### createBasicWMSLayer

- createBasicWMSLayer(sourceURL, sourceLayersName, sourceFormat, opt_serverType?, opt_time?, opt_params?, opt_crossOrigin?, opt_customSourceOptions?, opt_customLayerOptions?): ImageLayer<ImageSource>

- Create and return a basic WMS layer with only a source URL and a comma separated layers names (see import('ol/source/ImageWMS').default).

  #### Parameters

  - ##### sourceURL: string

    The source URL.

  - ##### sourceLayersName: string

    A comma separated names string.

  - ##### sourceFormat: string

    Image format, for example 'image/png'.

  - ##### `Optional` opt_serverType: string

    Type of the server ("mapserver", "geoserver", "qgisserver", …).

  - ##### `Optional` opt_time: string

    time parameter for layer queryable by time/period

  - ##### `Optional` opt_params: Object

    WMS parameters.

  - ##### `Optional` opt_crossOrigin: string

    crossOrigin.

  - ##### `Optional` opt_customSourceOptions: unknown

    Some layer's source initial options.

  - ##### `Optional` opt_customLayerOptions: unknown

    Some layer initial options.

  #### Returns ImageLayer<ImageSource>

  WMS Layer.

  - Defined in src/map/LayerHelper.js:145

### createBasicWMSLayerFromDataSource

- createBasicWMSLayerFromDataSource(dataSource, opt_crossOrigin?): ImageLayer<ImageSource>

- Create and return a basic WMS layer using an OGC data source.

  #### Parameters

  - ##### dataSource: GmfDatasourceOGC

    OGC data source.

  - ##### `Optional` opt_crossOrigin: string

    crossOrigin.

  #### Returns ImageLayer<ImageSource>

  WMS Layer.

  - Defined in src/map/LayerHelper.js:210

### createWMTSLayerFromCapabilitites

- createWMTSLayerFromCapabilitites(capabilitiesURL, layerName, opt_matrixSet?, opt_dimensions?, opt_customOptions?, opt_minResolution?, opt_maxResolution?, opt_opacity?): IPromise<any>

- Create and return a promise that provides a WMTS layer with source on success, no layer else. The WMTS layer source will be configured by the capabilities that are loaded from the given capabilitiesUrl. The style object described in the capabilities for this layer will be added as key 'capabilitiesStyles' as param of the new layer.

  #### Parameters

  - ##### capabilitiesURL: string

    The getCapabilities url.

  - ##### layerName: string

    The name of the layer.

  - ##### `Optional` opt_matrixSet: string

    Optional WMTS matrix set.

  - ##### `Optional` opt_dimensions: Object

    WMTS dimensions.

  - ##### `Optional` opt_customOptions: Object

    Some initial options.

  - ##### `Optional` opt_minResolution: number

    WMTS minimum resolution.

  - ##### `Optional` opt_maxResolution: number

    WMTS maximum resolution.

  - ##### `Optional` opt_opacity: number

    The opacity.

  #### Returns IPromise<any>

  A Promise with a layer (with source) on success, no layer else.

  - Defined in src/map/LayerHelper.js:275

### createWMTSLayerFromCapabilititesObj

- createWMTSLayerFromCapabilititesObj(capabilities, layerCap, opt_dimensions?): any

- Create and return a WMTS layer using a formatted capabilities response and a capability layer.

  #### Parameters

  - ##### capabilities: Object

    The complete capabilities object of the service

  - ##### layerCap: Object

    The layer capability object

  - ##### `Optional` opt_dimensions: Object

    WMTS dimensions.

  #### Returns any

  WMTS layer

  - Defined in src/map/LayerHelper.js:342

### fixResolution_

- fixResolution_(opt_maxResolution): number

- Small hack to get perfect sync with the on resolution status and the zoom to resolution.

  #### Parameters

  - ##### opt_maxResolution: number

    resolution.

  #### Returns number

  fixed maximum resolution.

  - Defined in src/map/LayerHelper.js:249

### getFlatLayers

- getFlatLayers(layer): Layer<Source, LayerRenderer<any>>[]

- Get an array of all layers in a group. The group can contain multiple levels of others groups.

  #### Parameters

  - ##### layer: BaseLayer

    The base layer, mostly a group of layers.

  #### Returns Layer<Source, LayerRenderer<any>>[]

  Layers.

  - Defined in src/map/LayerHelper.js:467

### getFlatLayers_

- getFlatLayers_(layer, array, computedOpacity): Layer<Source, LayerRenderer<any>>[]

- Get an array of all layers in a group. The group can contain multiple levels of others groups. When we flatten a group, we get the child layers. If opacity is defined on the group, this value is lost. Computed opacity is a custom 'back-up' value that contains the calculated value of all ancestors and the given layer.

  #### Parameters

  - ##### layer: BaseLayer

    The base layer, mostly a group of layers.

  - ##### array: Layer<Source, LayerRenderer<any>>[]

    An array to add layers.

  - ##### computedOpacity: number

    Opacity inherited from ancestor layer groups.

  #### Returns Layer<Source, LayerRenderer<any>>[]

  Layers.

  - Defined in src/map/LayerHelper.js:492

### getGroupFromMap

- getGroupFromMap(map, groupName): LayerGroup

- Retrieve (or create if it doesn't exist) and return a group of layer from the base array of layers of a map. The given name is used as unique identifier. If the group is created, it will be automatically added to the map.

  #### Parameters

  - ##### map: Map

    A map.

  - ##### groupName: string

    The name of the group.

  #### Returns LayerGroup

  The group corresponding to the given name.

  - Defined in src/map/LayerHelper.js:441

### getLayerByNodeName

- getLayerByNodeName(nodeName, layers): BaseLayer

- Get a layer that has the LAYER_NODE_NAME_KEY property equal to a given layer name from an array of layers. If one of the layers in the array is a group, then the layers contained in that group are searched as well.

  #### Parameters

  - ##### nodeName: string

    The node name of the layer we're looking for.

  - ##### layers: BaseLayer[]

    Layers.

  #### Returns BaseLayer

  Layer.

  - Defined in src/map/LayerHelper.js:522

### getQuerySourceIds

- getQuerySourceIds(layer): number[]

- #### Parameters

  - ##### layer: ImageLayer<ImageSource>

    The WMS layer.

  #### Returns number[]

  List of query source ids, a.k.a. the data source ids this layer is composed of.

  - Defined in src/map/LayerHelper.js:717

### getWMSLegendURL

- getWMSLegendURL(url, layerName, opt_scale?, opt_legendRule?, opt_legendWidth?, opt_legendHeight?, opt_servertype?, opt_dpi?, opt_bbox?, opt_srs?, opt_additionalQueryString?): string

- Get the WMS legend URL for the given node.

  #### Parameters

  - ##### url: string

    The base url of the wms service.

  - ##### layerName: string

    The name of a wms layer.

  - ##### `Optional` opt_scale: number

    A scale.

  - ##### `Optional` opt_legendRule: string

    rule parameters to add to the returned URL.

  - ##### `Optional` opt_legendWidth: number

    the legend width.

  - ##### `Optional` opt_legendHeight: number

    the legend height.

  - ##### `Optional` opt_servertype: string

    the OpenLayers server type.

  - ##### `Optional` opt_dpi: number

    the DPI.

  - ##### `Optional` opt_bbox: number[]

    the bbox.

  - ##### `Optional` opt_srs: string

    The projection code.

  - ##### `Optional` opt_additionalQueryString: Object

    Additional query string parameters.

  #### Returns string

  The legend URL or undefined.

  - Defined in src/map/LayerHelper.js:574

### getWMTSLegendURL

- getWMTSLegendURL(layer): string

- Get the WMTS legend URL for the given layer.

  #### Parameters

  - ##### layer: any

    Tile layer as returned by the ngeo layerHelper service.

  #### Returns string

  The legend URL or undefined.

  - Defined in src/map/LayerHelper.js:545

### isLayerVisible

- isLayerVisible(layer, map): boolean

- Returns if this layer is visible at the current resolution.

  #### Parameters

  - ##### layer: BaseLayer

    Layer.

  - ##### map: Map

    Map.

  #### Returns boolean

  Is the layer currently visible?

  - Defined in src/map/LayerHelper.js:642

### refreshWMSLayer

- refreshWMSLayer(layer): void

- Force a WMS layer to refresh using a random value.

  #### Parameters

  - ##### layer: any

    Layer to refresh.

  #### Returns void

  - Defined in src/map/LayerHelper.js:659

### setZIndexToFirstLevelChildren

- setZIndexToFirstLevelChildren(element, ZIndex): void

- Set ZIndex property to first level children elements

  #### Parameters

  - ##### element: BaseLayer | LayerGroup

    The group of layer with first level children layers.

  - ##### ZIndex: number

    The ZIndex for children element.

  #### Returns void

  - Defined in src/map/LayerHelper.js:677

### updateWMSLayerState

- updateWMSLayerState(layer, names, opt_time?): void

- Update the LAYERS parameter of the source of the given WMS layer.

  #### Parameters

  - ##### layer: ImageLayer<ImageSource>

    The WMS layer.

  - ##### names: string

    The names that will be used to set the LAYERS parameter.

  - ##### `Optional` opt_time: string

    The start and optionally the end datetime (for time range selection) selected by user in a ISO-8601 string datetime or time interval format

  #### Returns void

  - Defined in src/map/LayerHelper.js:694

Generated using TypeDoc