MapboxglLayerGroups

A plugin to manage layer groups in Mapbox GL JS

Create a MapboxglLayerGroups object bound to the map.

Parameters:
Name Type Description
map Map
Author:

Methods

addGroup(groupId, layers, beforeId)

Add a layer group to the map.

Parameters:
Name Type Description
groupId string

The id of the new group (use group/sub-group format to create a sub group)

layers Array.<Object>

The Mapbox style spec layers of the new group

beforeId string

The id of an existing layer or group to insert the new layers group before. If this argument is omitted, the layers group will be appended to the end of the layers array.

addLayerToGroup(groupId, layer, beforeId)

Add a single layer to an existing layer group.

Parameters:
Name Type Description
groupId string

The id of group

layer Object

The Mapbox style spec layer

beforeId string

The id of an existing layer to insert the new layer before. If this argument is omitted, the layer will be appended to the end of the layers group.

createGroupId() → {string}

Create a group id from a list of group names.

Returns:
string -

group id

getGroupFirstLayerId(groupId) → {string}

Get the id of the first layer in a group.

Parameters:
Name Type Description
groupId string

The id of the group.

Returns:
string

getGroupLastLayerId(groupId) → {string}

Get the id of the last layer in a group.

Parameters:
Name Type Description
groupId string

The id of the group.

Returns:
string

getLayerGroupIds(id) → {array}

Get an array of group ids for a specified layer id.

Parameters:
Name Type Description
id string

The layer id.

Returns:
array -

array of strings

getLayersInGroup(groupId) → {array}

List all layers that belongs to the group id.

Parameters:
Name Type Description
groupId string

group id to test.

Returns:
array -

array of layers

moveGroup(groupId, beforeId)

Remove a layer group and all of its layers from the map.

Parameters:
Name Type Description
groupId string

The id of the group to be moved.

beforeId string

The id of an existing layer or group to insert the new layers group before. If this argument is omitted, the layer will be appended to the end of the layers array.

removeGroup(groupId)

Remove a layer group and all of its layers from the map.

Parameters:
Name Type Description
groupId string

The id of the group to be removed.