Skip to content

ym.modules.provider.FeatureGroup

Overview

Extended layerGroup, which also contains mouse events (triggered by members of the group) and a common bindPopup method. Implements the ILayer interface.

ym.featureGroup([marker1, marker2, polyline])
    .bindPopup('Hello world!')
    .on('click', function() { alert('Clicked on a group!'); })
    .addTo(map);

Initialization

Factory: ym.featureGroup(layers)

  • Parameter
  • layers
    • Description: The initial set of layers. [optional]
    • Data type: ILayer[]

Methods

bindPopup(htmlContent, options)

Binds a popup with specific HTML content to a click on any level in the group that has a bindPopup method.

  • Parameters
  • htmlContent

    • Data type: string
  • options

    • Data type: [optional]
  • Return: this

getBounds()

Returns the LatLngBounds of the feature group, created from the boundaries and coordinates of its children.

  • Return: LatLngBounds

setStyle(style)

Sets the specified path options for each level of the group that has a setStyle method.

  • Parameter
  • style

    • Data type:
  • Return: this

bringToFront()

Brings the layer group to the top edge of all other layers.

  • Return: this

bringToBack()

Brings the layer group to the bottom edge of all other layers.

  • Return: this

Events

You can react to the following events:

  • click
  • Event type: MouseEvent
  • Description: Triggered when the user clicks (or taps) on the group.

  • dblclick

  • Event type: MouseEvent
  • Description: Triggered when the user double-clicks (or double-taps) on the group.

  • mouseover

  • Event type: MouseEvent
  • Description: Triggered when the mouse pointer moves over the group.

  • mouseout

  • Event type: MouseEvent
  • Description: Triggered when the mouse pointer moves out of the group.

  • mousemove

  • Event type: MouseEvent
  • Description: Triggered while the mouse is moved over the layers of the group.

  • contextmenu

  • Event type: MouseEvent
  • Description: Triggered when the user right-clicks on one of the layers.

  • layeradd

  • Event type: LayerEvent
  • Description: Triggered when a layer is added to the group.

  • layerremove

  • Event type: LayerEvent
  • Description: Triggered when a layer is removed from the group.