ym.modules.provider.LayerGroup

Overview

Used to group several layers and treat them as one. When you add a layer to the map, all the layers added to or removed from the group are also added or removed on the map.

Initialization

Factory: ym.layerGroup(layers)

Create a layer group (optionally with an initial set of layers).

Parameter

Name Description Data type Default value
layers [optional] ILayer[]  

Methoden

addTo(map) ab v3

Adds the layer group to the map.

Parameter

Name Description Data type Default value
map   Map  

Return

this

addLayer(layer) ab v3

Adds a specific layer to the group.

Parameter

Name Description Data type Default value
layer   ILayer  

Return

this

removeLayer(layer) ab v3

Removes a specific layer from the group.

Parameter

Name Description Data type Default value
layer   ILayer  

Return

this

removeLayer(id) ab v3

Removes a given layer of the specified ID from the group.

Parameter

Name Description Data type Default value
id   string  

Return

this

hasLayer(layer) ab v3

Returns true when the specified layer is added to the group.

Parameter

Name Description Data type Default value
layer   ILayer  

Return

bool

getLayer(id) ab v3

Returns the layer with the specified ID.

Parameter

Name Description Data type Default value
id   string  

Return

ILayer

getLayers() ab v3

Returns an array of all layers added to the group.

Return

ILayer[]

clearLayers() ab v3

Removes all layers from the group.

Return

this

eachLayer(fn, context) ab v3

Iterates over the layers of the group and optionally gives the context of the iterator function.

group.eachLayer(function (layer) {    
layer.bindPopup('Hello');
});

Parameter

Name Description Data type Default value
fn   Function  
context [optional] Object  

Return

this

toGeoJSON() ab v3

Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection)

Return

Object