Create a MapboxglLayerGroups object bound to the map.
Parameters:
| Name | Type | Description |
|---|---|---|
map |
Map |
Methods
-
addGroup(groupId, layers, beforeId)
-
Add a layer group to the map.
Parameters:
Name Type Description groupIdstring The id of the new group (use
group/sub-groupformat to create a sub group)layersArray.<Object> The Mapbox style spec layers of the new group
beforeIdstring 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 groupIdstring The id of group
layerObject The Mapbox style spec layer
beforeIdstring 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 groupIdstring The id of the group.
Returns:
string -
getGroupLastLayerId(groupId) → {string}
-
Get the id of the last layer in a group.
Parameters:
Name Type Description groupIdstring 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 idstring The layer id.
Returns:
array -array of strings
-
getLayersInGroup(groupId) → {array}
-
List all layers that belongs to the group id.
Parameters:
Name Type Description groupIdstring 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 groupIdstring The id of the group to be moved.
beforeIdstring 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 groupIdstring The id of the group to be removed.