LayerGroup
Used to group several layers and handle them as one. If you add it to the map, any layers added or removed from the group will be added/removed on the map as well. Implements ILayer interface.
L.layerGroup([marker1, marker2])
.addLayer(polyline)
.addTo(map);
Creation
Factory | Description |
---|---|
L.LayerGroup(
|
Create a layer group, optionally given an initial set of layers. |
Methods
Method | Returns | Description |
---|---|---|
addTo(
|
this |
Adds the group of layers to the map. |
addLayer(
|
this |
Adds a given layer to the group. |
removeLayer(
|
this |
Removes a given layer from the group. |
removeLayer(
|
this |
Removes a given layer of the given id from the group. |
hasLayer(
|
Boolean |
Returns true if the given layer is currently added to the group. |
getLayer(
|
ILayer |
Returns the layer with the given id. |
getLayers() |
Array |
Returns an array of all the layers added to the group. |
clearLayers() |
this |
Removes all the layers from the group. |
eachLayer(
|
this |
Iterates over the layers of the group, optionally specifying context of the iterator function.
|
toGeoJSON() |
Object |
Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection). |