Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GeoJSON

Hierarchy

Implements

Index

Constructors

constructor

  • Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format to display on the map (you can alternatively add it later with addData method) and an options object.

    Parameters

    Returns GeoJSON

Methods

addData

  • addData(data: any): boolean
  • Adds a GeoJSON object to the layer.

    Parameters

    • data: any

    Returns boolean

addEventListener

addLayer

addOneTimeEventListener

  • addOneTimeEventListener(type: string, fn: function, context?: any): FeatureGroup<ILayer>

addTo

bindPopup

  • Binds a popup with a particular HTML content to a click on any layer from the group that has a bindPopup method.

    Parameters

    Returns FeatureGroup<ILayer>

bringToBack

bringToFront

clearAllEventListeners

clearLayers

eachLayer

  • Iterates over the layers of the group, optionally specifying context of the iterator function.

    Parameters

    • fn: function
        • Parameters

          Returns void

    • Optional context: any

    Returns LayerGroup<ILayer>

fire

fireEvent

getBounds

  • Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

    Returns LatLngBounds

getLayer

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

    Parameters

    • id: string

    Returns ILayer

getLayerId

  • getLayerId(layer: ILayer): string

getLayers

  • Returns an array of all the layers added to the group.

    Returns ILayer[]

hasEventListeners

  • hasEventListeners(type: string): boolean

hasLayer

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

    Parameters

    Returns boolean

off

on

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

once

removeEventListener

removeLayer

resetStyle

  • Resets the the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events.

    Parameters

    Returns GeoJSON

setStyle

  • Changes styles of GeoJSON vector layers with the given style function.

    Parameters

    • style: function
        • (featureData: any): any
        • Parameters

          • featureData: any

          Returns any

    Returns GeoJSON

  • Changes styles of GeoJSON vector layers with the given style options.

    Parameters

    Returns GeoJSON

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 coordsToLatlng

  • coordsToLatlng(coords: number[], reverse?: boolean): LatLng
  • Creates a LatLng object from an array of 2 numbers (latitude, longitude) used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted as (longitude, latitude).

    Parameters

    • coords: number[]
    • Optional reverse: boolean

    Returns LatLng

Static coordsToLatlngs

  • coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[]
  • Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). If reverse is set to true, the numbers will be interpreted as (longitude, latitude).

    Parameters

    • coords: number[]
    • Optional levelsDeep: number
    • Optional reverse: boolean

    Returns LatLng[]

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

Static geometryToLayer

  • geometryToLayer(featureData: GeoJSON, pointToLayer?: function): ILayer
  • Creates a layer from a given GeoJSON feature.

    Parameters

    • featureData: GeoJSON
    • Optional pointToLayer: function

    Returns ILayer