ol-ishare/olutil

Handy utilities to make working with OpenLayers easier

Methods

(inner) findLayersFilter(layer, group) → {Boolean}

Filter function signatures for ol-ishare/findLayers.

Parameters:
Name Type Description
layer ol/layer/Base~BaseLayer

The candidate layer

group ol/layer/Group~LayerGroup

The group that the layer belongs to

Returns:

Whether the layer should be included in the results

Type
Boolean

(inner) findLayers(layerGroup, filter) → {Array.<ol/layer/Base~BaseLayer>}

Find layers that are a decendent of the given layerGroup by testing each with a filter

Parameters:
Name Type Description
layerGroup ol/layer/Group~LayerGroup

The layer group to search recursively (commonly map.getLayerGroup())

filter module:ol-ishare/olutil~findLayersFilter

Function called for each layer found to determine whether to include it in the returned array

Returns:

Array of layers which satisfy the filter

Type
Array.<ol/layer/Base~BaseLayer>

(inner) getVisibleLayers(layerGroup) → {Array.<ol/layer/Base~BaseLayer>}

Find all visible layers in a given layer group

Parameters:
Name Type Description
layerGroup ol/layer/group~Group

The layer group to search recursively

Returns:

All layers currently set to visible

Type
Array.<ol/layer/Base~BaseLayer>

(inner) getLayerByName(layerGroup, layerName) → {ol/layer/Base~BaseLayer|null}

Find the first layer that is a decendant of the given layerGroup with the given iShare layerName.

Parameters:
Name Type Description
layerGroup ol/layer/group~Group

The layer group to search recursively (commonly map.getLayerGroup())

layerName String

The iShare layerName to search for (as defined in the profile)

Returns:

First layer with the given layerName or null if not found

Type
ol/layer/Base~BaseLayer | null

(inner) getGroupByGuid(layerGroup, guid) → {ol/layer/Group~LayerGroup|null}

Find the first group that is a decendant of the given layerGroup with the given iShare GUID (groups have GUIDs not names).

Parameters:
Name Type Description
layerGroup ol/layer/group~Group

The layer group to search recursively (commonly map.getLayerGroup())

guid String

The iShare group GUID to search for (as defined in the profile)

Returns:

First group with the given GUID, or null if not found

Type
ol/layer/Group~LayerGroup | null

(inner) getGroupContainingLayer(layerGroup, layer) → {ol/layer/Base~BaseLayer|null}

Gets the Group that a given Layer is contained within

Parameters:
Name Type Description
layerGroup ol/layer/Group~LayerGroup

The layer group to search recursively (commonly map.getLayerGroup())

layer ol/layer/Base~BaseLayer

The layer that the Group your trying to find is a child of

Returns:

Group containing the layer or null if not found

Type
ol/layer/Base~BaseLayer | null

(inner) getInteractionByType(interactions, type) → {ol/interaction/Interaction~Interaction|null}

Returns the first interaction in the interactions Collection of a given type

Parameters:
Name Type Description
interactions ol/Collection.<ol/interaction/Interaction>

Collection of interactions to search

type Class

Type of the interaction to find via instanceof

Returns:

The first interaction of the specified type or null if not found

Type
ol/interaction/Interaction~Interaction | null

(inner) getBaseLayers(map) → {Array.<ol/layer/Base~BaseLayer>}

Returns iShare basemap layers from OpenLayers map

Parameters:
Name Type Description
map ol/Map~Map

Map instance created from iShare profile using LiteMap or similar

Returns:

All basemap layers

Type
Array.<ol/layer/Base~BaseLayer>

(inner) getCurrentBaseLayer(map) → {ol/layer/Base~BaseLayer}

Returns first iShare basemap layer currently shown on the map

If more than one basemap is shown then use getBasemapLayers and filter on .getVisible() to return them all

Parameters:
Name Type Description
map ol/Map~Map

Map instance created from iShare profile using LiteMap or similar

Returns:

Current basemap layer

Type
ol/layer/Base~BaseLayer

(inner) inherits(childCtornon-null, parentCtornon-null)

Inherit the prototype methods from one constructor into another.

Usage:

function ParentClass(a, b) { }
ParentClass.prototype.foo = function(a) { }

function ChildClass(a, b, c) {
  // Call parent constructor
  ParentClass.call(this, a, b);
}
inherits(ChildClass, ParentClass);

var child = new ChildClass('a', 'b', 'see');
child.foo(); // This works.
Parameters:
Name Type Description
childCtor function

Child constructor.

parentCtor function

Parent constructor.