Class: LayerHelper service:ngeoLayerHelper

ngeo.map.LayerHelper

new LayerHelper($q, $http)

Provides help functions that helps you to create and manage layers.

Parameters:
Name Type Description
$q angular.$q

Angular promises/deferred service.

$http angular.$http

Angular http service.

Members

(static, constant) GROUP_KEY

(static, non-null) module: angular.Module

(static, constant) REFRESH_PARAM

Methods

createBasicGroup([opt_layers]opt)

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

Parameters:
Name Type Attributes Description
[opt_layers] ol.Collection.= <optional>

The layer to add to the returned Group.

Returns:
ol.layer.Group

Layer group.

createBasicWMSLayer(sourceURL, sourceLayersName, sourceFormat, [opt_serverType]opt, [opt_time]opt, [opt_params]opt, [opt_crossOrigin]opt)

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

Parameters:
Name Type Attributes Description
sourceURL string

The source URL.

sourceLayersName string

A comma separated names string.

sourceFormat string

Image format, for example 'image/png'.

[opt_serverType] string= <optional>

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

[opt_time] string= <optional>

time parameter for layer queryable by time/periode

[opt_params] Object.= <optional>

WMS parameters.

[opt_crossOrigin] string= <optional>

crossOrigin.

Returns:
ol.layer.Image

WMS Layer.

createBasicWMSLayerFromDataSource(dataSource, [opt_crossOrigin]opt)

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

Parameters:
Name Type Attributes Description
dataSource ngeo.datasource.OGC

OGC data source.

[opt_crossOrigin] string= <optional>

crossOrigin.

Returns:
ol.layer.Image

WMS Layer.

createWMTSLayerFromCapabilitites(capabilitiesURL, layerName, [opt_dimensions]opt)

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:
Name Type Attributes Description
capabilitiesURL string

The getCapabilities url.

layerName string

The name of the layer.

[opt_dimensions] Object.= <optional>

WMTS dimensions.

Returns:
angular.$q.Promise.

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

createWMTSLayerFromCapabilititesObj(capabilities, layerCap, [opt_dimensions]opt)

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

Parameters:
Name Type Attributes Description
capabilities !Object

The complete capabilities object of the service

layerCap !Object

The layer capability object

[opt_dimensions] Object.= <optional>

WMTS dimensions.

Returns:
!ol.layer.Tile

WMTS layer

getFlatLayers(layer)

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

Parameters:
Name Type Description
layer ol.layer.Base

The base layer, mostly a group of layers.

Returns:
Array.

Layers.

getGroupFromMap(map, groupName)

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:
Name Type Description
map ol.Map

A map.

groupName string

The name of the group.

Returns:
ol.layer.Group

The group corresponding to the given name.

getLayerByName(layerName, layers)

Get a layer that has a layerName 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:
Name Type Description
layerName string

The name of the layer we're looking for.

layers Array.

Layers.

Returns:

getQuerySourceIds(layer)

Parameters:
Name Type Description
layer ol.layer.Image

The WMS layer.

Returns:
Array.|undefined

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

getWMSLegendURL(url, layerName, [opt_scale]opt, [opt_legendRule]opt)

Get the WMS legend URL for the given node.

Parameters:
Name Type Attributes Description
url string|undefined

The base url of the wms service.

layerName string

The name of a wms layer.

[opt_scale] number= <optional>

A scale.

[opt_legendRule] string= <optional>

rule parameters to add to the returned URL.

Returns:
string|undefined

The legend URL or undefined.

getWMTSLegendURL(layer)

Get the WMTS legend URL for the given layer.

Parameters:
Name Type Description
layer ol.layer.Tile

Tile layer as returned by the ngeo layerHelper service.

Returns:
string|undefined

The legend URL or undefined.

isLayerVisible(layer, map)

Returns if this layer is visible at the current resolution.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

map ol.Map

Map.

Returns:
boolean

Is the layer currently visible?

refreshWMSLayer(layer)

Force a WMS layer to refresh using a random value.

Parameters:
Name Type Description
layer ol.layer.Image|ol.layer.Tile

Layer to refresh.

updateWMSLayerState(layer, names, [opt_time]opt)

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

Parameters:
Name Type Attributes Description
layer ol.layer.Image

The WMS layer.

names string

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

[opt_time] string= <optional>

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