FeatureGroup
Extended layerGroup that also has mouse events (propagated from members of the group) and a shared bindPopup method. Implements ILayer interface.
L.featureGroup([marker1, marker2, polyline])
.bindPopup('Hello world!')
.on('click', function() { alert('Clicked on a group!'); })
.addTo(map);
Creation
Factory | Description |
---|---|
L.featureGroup(
|
Create a layer group, optionally given an initial set of layers. |
Methods
Has all layerGroup methods and additionally:
Method | Returns | Description |
---|---|---|
bindPopup(
|
this |
Binds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method. |
getBounds() |
LatLngBounds |
Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children). |
setStyle(
|
this |
Sets the given path options to each layer of the group that has a setStyle method. |
bringToFront() |
this |
Brings the layer group to the top of all other layers. |
bringToBack() |
this |
Brings the layer group to the bottom of all other layers. |
Events
You can subscribe to the following events using these methods.
Event | Data | Description |
---|---|---|
click |
MouseEvent |
Fired when the user clicks (or taps) the group. |
dblclick |
MouseEvent |
Fired when the user double-clicks (or double-taps) the group. |
mouseover |
MouseEvent |
Fired when the mouse enters the group. |
mouseout |
MouseEvent |
Fired when the mouse leaves the group. |
mousemove |
MouseEvent |
Fired while the mouse moves over the layers of the group. |
contextmenu |
MouseEvent |
Fired when the user right-clicks on one of the layers. |
layeradd |
LayerEvent
| Fired when a layer is added to the group. |
layerremove |
LayerEvent
| Fired when a layer is removed from the map. |