Layer Group#
Example#
from ipyleaflet import (
Map, basemaps, basemap_to_tiles,
Circle, Marker, Rectangle, LayerGroup
)
toner = basemap_to_tiles(basemaps.Stadia.StamenTerrain)
m = Map(layers=(toner, ), center=(50, 354), zoom=5)
# Create some layers
marker = Marker(location=(50, 354))
circle = Circle(location=(50, 370), radius=50000, color="yellow", fill_color="yellow")
rectangle = Rectangle(bounds=((54, 354), (55, 360)), color="orange", fill_color="orange")
# Create layer group
layer_group = LayerGroup(layers=(marker, circle))
m.add(layer_group)
layer_group.add_layer(rectangle)
layer_group.remove_layer(circle)
m
Attributes and methods#
- class ipyleaflet.leaflet.LayerGroup(**kwargs: Any)[source]#
LayerGroup class.
A group of layers that you can put on the map like other layers.
- layers#
List of layers to include in the group.
- Type:
list, default []
- add(layer)[source]#
Add a new layer to the group.
- Parameters:
layer (layer instance) – The new layer to include in the group. This can also be an object with an
as_leaflet_layer
method which generates a compatible layer type.
- add_layer(layer)[source]#
Add a new layer to the group.
Deprecated since version 0.17.0: Use add method instead.
- Parameters:
layer (layer instance) – The new layer to include in the group.
- clear_layers()[source]#
Remove all layers from the group.
Deprecated since version 0.17.0: Use clear method instead.
- remove(rm_layer)[source]#
Remove a layer from the group.
- Parameters:
layer (layer instance) – The layer to remove from the group.
- remove_layer(rm_layer)[source]#
Remove a layer from the group.
Deprecated since version 0.17.0: Use remove method instead.
- Parameters:
layer (layer instance) – The layer to remove from the group.