Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LayerGroup<T>

Type parameters

Hierarchy

Implements

Index

Constructors

constructor

  • Create a layer group, optionally given an initial set of layers.

    Parameters

    • Optional layers: T[]

    Returns LayerGroup

Methods

addLayer

  • Adds a given layer to the group.

    Parameters

    • layer: T

    Returns LayerGroup<T>

addTo

  • Adds the group of layers to the map.

    Parameters

    Returns LayerGroup<T>

clearLayers

  • Removes all the layers from the group.

    Returns LayerGroup<T>

eachLayer

  • eachLayer(fn: function, context?: any): LayerGroup<T>
  • Iterates over the layers of the group, optionally specifying context of the iterator function.

    Parameters

    • fn: function
        • (layer: T): void
        • Parameters

          • layer: T

          Returns void

    • Optional context: any

    Returns LayerGroup<T>

getLayer

  • getLayer(id: string): T
  • Returns the layer with the given id.

    Parameters

    • id: string

    Returns T

getLayerId

  • getLayerId(layer: ILayer): string
  • Parameters

    Returns string

getLayers

  • getLayers(): T[]
  • Returns an array of all the layers added to the group.

    Returns T[]

hasLayer

  • hasLayer(layer: T): boolean
  • Returns true if the given layer is currently added to the group.

    Parameters

    • layer: T

    Returns boolean

onAdd

  • onAdd(map: Map): void
  • Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).

    Parameters

    Returns void

onRemove

  • onRemove(map: Map): void
  • Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).

    Parameters

    Returns void

removeLayer

  • Removes a given layer from the group.

    Parameters

    • layer: T

    Returns LayerGroup<T>

  • Removes a given layer of the given id from the group.

    Parameters

    • id: string

    Returns LayerGroup<T>

toGeoJSON

  • toGeoJSON(): any
  • Returns a GeoJSON representation of the layer group (GeoJSON FeatureCollection).

    Returns any

Static addInitHook

  • addInitHook(methodName: string, ...args: any[]): void
  • You can also use the following shortcut when you just need to make one additional method call.

    Parameters

    • methodName: string
    • Rest ...args: any[]

    Returns void

Static extend

  • You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it.

    Parameters

    Returns any