Class: MapUtil

MapUtil()

Helper Class for the ol3 map.

Constructor

new MapUtil()

Source:

Members

getLayerByOlUid

Get a layer by its key (ol_uid).

Source:

Methods

(static) getAllLayers(collection, filteropt) → {Array}

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

Parameters:
Name Type Attributes Description
collection ol.Map | ol.layer.Group

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

filter function <optional>

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

Source:
Returns:

An array of all Layers.

Type
Array

(static) getInteractionsByClass(map, clazz) → {Array.<ol.interaction>}

Returns all interactions by the given name of a map.

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

clazz ol.interaction

The class of the interaction to look for.

Source:
Returns:

The list of result interactions.

Type
Array.<ol.interaction>

(static) getInteractionsByName(map, name) → {Array.<ol.interaction>}

Returns all interactions by the given name of a map.

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

name String

The name of the interaction to look for.

Source:
Returns:

The list of result interactions.

Type
Array.<ol.interaction>

(static) getLayerByFeature(map, feature, namespaces) → {ol.Layer}

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

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

feature ol.Feature

The feature to get the layer by.

namespaces Array

list of supported GeoServer namespaces.

Source:
Returns:

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

Type
ol.Layer

(static) getLayerByName(map, name) → {ol.Layer}

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

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

name String

The name to get the layer by.

Source:
Returns:

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

Type
ol.Layer

(static) getLayerByNameParam(map, name) → {ol.Layer}

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

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

name String

The name to get the layer by.

Source:
Returns:

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

Type
ol.Layer

(static) getLayerPositionInfo(layer, groupLayerOrMapopt) → {Object}

Get information about the LayerPosition in the tree.

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

The layer to get the information.

groupLayerOrMap ol.layer.Group | ol.Map <optional>

The groupLayer or map containing the layer.

Source:
Returns:

An object with these keys: {ol.layer.Group} groupLayer The groupLayer containing the layer. {Integer} position The position of the layer in the collection.

Type
Object

(static) getLayersByGroup(map, layerGroup) → {Array}

Returns all layers of the specified layer group recursively.

Parameters:
Name Type Description
map ol.Map

The map to use for lookup.

layerGroup ol.Layer.Group

The group to flatten.

Source:
Returns:

The (flattened) layers from the group

Type
Array

(static) getLegendGraphicUrl(layer) → {String|undefined}

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

  • ol.source.TileWms (with url configured)
Parameters:
Name Type Description
layer ol.layer.Layer

The layer that you want to have a legendUrlfor.

Source:
Returns:

The getLegendGraphicUrl.

Type
String | undefined

(static) getResolutionForScale(scale, units) → {Number}

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:
Name Type Description
scale Number

The input scale to calculate the appropriate resolution for.

units String

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

Source:
Returns:

The calculated resolution.

Type
Number

(static) getScaleForResolution(resolution, units) → {Number}

Returns the appropriate scale for the given resolution and units.

Parameters:
Name Type Description
resolution Number

The resolutions to calculate the scale for.

units String

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

Source:
Returns:

The appropriate scale.

Type
Number

(static) layerInResolutionRange(layer, map) → {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:
Name Type Description
layer ol.layer.Layer

The layer to check.

map ol.Map

The map to get the view resolution for comparison from.

Source:
Returns:

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).

Type
Boolean

(static) roundScale(scale) → {Number}

Rounds a scalenumber in dependency to its size.

Parameters:
Name Type Description
scale Number

The exact scale

Source:
Returns:

The roundedScale

Type
Number