Home Reference Source Repository

Function

Static Public Summary
public

A mixin that encapsulates the creation, update, and removal of a CircleMarker.

public

CoverageMixin(base: class): class

A mixin that encapsulates loading of a single coverage for use in layers.

public

DraggablePopupMixin(base: class): class

Makes L.Popup draggable and proxies all L.Draggable events.

public

EventMixin(base: class): class

Wraps Leaflet's L.Evented for use within class expressions.

public

PaletteMixin(base: class): class

A mixin that encapsulates the palette logic of a coverage layer, supporting categorical and continuous coverage parameters.

public

cssToRGB(cssColor: string): Object

Converts any CSS color to an {r,g,b} object.

public

dataLayer(cov: *, options: *): function

Creates a layer for a given coverage data object or throws an error if no layer class could be found.

public

Return a layer class usable for the given coverage data object, or undefined if none was found.

public

Converts an array of CSS colors to a palette of the same size.

public

Convenience function that returns a legend control based on the coverage parameter type.

public

linearPalette(colors: Array<string>, steps: number): Palette

Returns a linearly interpolated palette out of CSS colors.

public

paletteFromObject(paletteSpec: *): Palette

Create a palette from a description object.

Static Public

public CircleMarkerMixin(base: PointDataLayer): class source

import {CircleMarkerMixin} from 'leaflet-coverage/'

A mixin that encapsulates the creation, update, and removal of a CircleMarker.

It provides the public methods bindPopup, openPopup, closePopup, and redraw.

See Point and VerticalProfile for usage.

Params:

NameTypeAttributeDescription
base PointDataLayer

The base class implementing the PointDataLayer interface.

Return:

class

The base class with CircleMarkerMixin.

public CoverageMixin(base: class): class source

import {CoverageMixin} from 'leaflet-coverage/'

A mixin that encapsulates loading of a single coverage for use in layers.

The base class must supply the following functions/properties:

.coverage .parameter (optional) ._loadCoverageSubset() (optional)

The following functions/properties are supplied:

.domain (after calling load()) .range (after calling load(); only if .parameter is set and ._loadCoverageSubset is undefined)

Params:

NameTypeAttributeDescription
base class

The base class.

Return:

class

The base class with CoverageMixin.

public DraggablePopupMixin(base: class): class source

import {DraggablePopupMixin} from 'leaflet-coverage/'

Makes L.Popup draggable and proxies all L.Draggable events.

Params:

NameTypeAttributeDescription
base class

The base class.

Return:

class

The base class with DraggablePopupMixin.

Example:

let DraggablePopup = DraggablePopupMixin(L.Popup)
let popup = new DraggablePopup().setContent('I am draggable!')

public EventMixin(base: class): class source

import {EventMixin} from 'leaflet-coverage/'

Wraps Leaflet's L.Evented for use within class expressions.

Params:

NameTypeAttributeDescription
base class

The base class.

Return:

class

The base class with Leaflet's L.Evented.

See:

public PaletteMixin(base: class): class source

import {PaletteMixin} from 'leaflet-coverage/'

A mixin that encapsulates the palette logic of a coverage layer, supporting categorical and continuous coverage parameters.

The following functions/properties are supplied:

  • initializePalette() - to be called once data has been loaded so that computePaletteExtent can be called
  • get/set palette
  • get/set paletteExtent
  • setPaletteExtent(extent) - like set paletteExtent, but returns a Promise to know when calculations etc. are done
  • getPaletteIndex(val) - returns the color index for the given value

The base class must supply the following functions/properties:

  • options.palette (optional)
  • options.paletteExtent (optional) - initial value that computePaletteExtent is called with
  • parameter
  • redraw()
  • computePaletteExtent(extent) - returns a Promise with the computed extent; gets called when .paletteExtent is set to a string value
  • canUsePalette() (optional) - if this method exists and returns false, then .palette returns undefined

Params:

NameTypeAttributeDescription
base class

The base class.

Return:

class

The base class with PaletteMixin.

public cssToRGB(cssColor: string): Object source

import {cssToRGB} from 'leaflet-coverage/'

Converts any CSS color to an {r,g,b} object.

Params:

NameTypeAttributeDescription
cssColor string

The CSS color

Return:

Object

An object with r,g,b members with each a number in [0,255].

Example:

let rgb = cssToRGB('white') // {r: 255, g: 255, b: 255}

public dataLayer(cov: *, options: *): function source

import {dataLayer} from 'leaflet-coverage/'

Creates a layer for a given coverage data object or throws an error if no layer class could be found.

This is a convenience function over using dataLayerClass and manually instantiating the layer.

Params:

NameTypeAttributeDescription
cov *
options *

Return:

function

A function fn(cov, options) which returns a new layer for the given coverage data object and which is initialized with the given layer options.

Throw:

Error

If no layer class could be found.

Example:

var cov = ...
var layer = C.dataLayer(cov, {parameter: 'temperature'}).addTo(map)
 

public dataLayerClass(cov: object): class | undefined source

import {dataLayerClass} from 'leaflet-coverage/'

Return a layer class usable for the given coverage data object, or undefined if none was found. If multiple layers match, then an arbitrary one is returned.

Params:

NameTypeAttributeDescription
cov object

The coverage data object.

Return:

class | undefined

The layer class.

Example:

var cov = ...
var clazz = C.dataLayerClass(cov)
if (clazz) {
  var layer = new clazz(cov, {parameter: 'temperature'}).addTo(map)
}

public directPalette(colors: Array<string>): Palette source

import {directPalette} from 'leaflet-coverage/'

Converts an array of CSS colors to a palette of the same size.

Params:

NameTypeAttributeDescription
colors Array<string>

An array of CSS colors.

Return:

Palette

Example:

var bw = C.directPalette(['#000000', '#FFFFFF'])
// bw.steps == 2

public legend(layer: object, options: object): DiscreteLegend | ContinuousLegend source

import {legend} from 'leaflet-coverage/'

Convenience function that returns a legend control based on the coverage parameter type. For categorical parameters this returns a DiscreteLegend, otherwise a ContinuousLegend instance.

Note that custom HTML templates cannot be used with this function. If this is necessary, consider using the individual legend classes instead.

Params:

NameTypeAttributeDescription
layer object

The coverage data layer.

options object
  • optional

Legend options.

options.position string
  • optional
  • default: 'bottomright'

The initial position of the control (see Leaflet docs).

options.language string
  • optional

A language tag, indicating the preferred language to use for labels.

Example:

Coverage data layer
var legend = C.legend(covLayer).addTo(map)
Fake layer
// see DiscreteLegend and ContinuousLegend docs

public linearPalette(colors: Array<string>, steps: number): Palette source

import {linearPalette} from 'leaflet-coverage/'

Returns a linearly interpolated palette out of CSS colors.

Params:

NameTypeAttributeDescription
colors Array<string>

An array of CSS colors.

steps number
  • optional
  • default: 256

The number of palette colors to generate.

Return:

Palette

Example:

var grayscale = C.linearPalette(['#FFFFFF', '#000000'])
var rainbow = C.linearPalette(['#0000FF', '#00FFFF', '#00FF00', '#FFFF00', '#FF0000'])

public paletteFromObject(paletteSpec: *): Palette source

import {paletteFromObject} from 'leaflet-coverage/'

Create a palette from a description object.

Currently, two forms are supported:

{ "colors": ["red", "blue", ..] "interpolation": "linear", "steps": 200 }

{ "colors": ["red", "blue", ..] }

Params:

NameTypeAttributeDescription
paletteSpec *

Return:

Palette