Home Reference Source Repository

Function

Static Public Summary
public

$(selector: string, parent: string | Element): Array<Element>

Returns all child elements of parent (fall-back to document if not given) matching the given selector as an array.

public

$$(selector: string, parent: string | Element): Element

Returns the first child element of parent (fall-back to document if not given) matching the given selector.

public

EventMixin(base: class): class

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

public

Turns an HTML string into an array of DOM elements.

public

Turns an HTML string into a DOM element.

public

add(nodes: string | Node | Array<Node>, el: Node)

Adds the given nodes as children to the given parent node.

public

darken(hex: string, ratio: number): string

Darken a given hex color by a given ratio.

public

Loads the given GeoJSON URL and returns a Leaflet GeoJSON layer that contains a child layer for each cluster.

public

Loads the given GeoJSON URL and returns a Leaflet GeoJSON layer that contains a child layer for each country.

Static Public

public $(selector: string, parent: string | Element): Array<Element> source

import {$} from './util/dom.js'

Returns all child elements of parent (fall-back to document if not given) matching the given selector as an array.

Params:

NameTypeAttributeDescription
selector string

A CSS selector.

parent string | Element
  • optional

The element to search within, or document by default.

Return:

Array<Element>

Example:

let items = $('.item', '#list')

public $$(selector: string, parent: string | Element): Element source

import {$$} from './util/dom.js'

Returns the first child element of parent (fall-back to document if not given) matching the given selector.

Params:

NameTypeAttributeDescription
selector string

A CSS selector.

parent string | Element
  • optional

The element to search within, or document by default.

Return:

Element

Example:

let element = $$('.myclass')

public EventMixin(base: class): class source

import EventMixin from './util/EventMixin.js'

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 HTML(html: string): Array<Element> source

import {HTML} from './util/dom.js'

Turns an HTML string into an array of DOM elements.

Params:

NameTypeAttributeDescription
html string

The HTML string out of which to create the single DOM element.

Return:

Array<Element>

Example:

let html = '<li>foo</li><li>bar</li>'
let elements = HTML(html)
add(elements, document.body)

public HTMLone(html: string): Element source

import {HTMLone} from './util/dom.js'

Turns an HTML string into a DOM element. The HTML markup must have a single root node, whitespace is ignored.

Params:

NameTypeAttributeDescription
html string

The HTML string out of which to create the single DOM element.

Return:

Element

Example:

let html = '<li>text</li>'
let element = HTMLone(s)
document.body.appendChild(element)

public add(nodes: string | Node | Array<Node>, el: Node) source

import {add} from './util/dom.js'

Adds the given nodes as children to the given parent node.

Params:

NameTypeAttributeDescription
nodes string | Node | Array<Node>

The nodes to add to el.

el Node

The parent node.

Example:

let elements = HTML('<li>foo</li><li>bar</li>')
add(elements, document.body)

public darken(hex: string, ratio: number): string source

import {darken} from './layers/util.js'

Darken a given hex color by a given ratio. If negative, lighten up.

Params:

NameTypeAttributeDescription
hex string

A non-abbreviated hex colour, e.g. '#00FF00'.

ratio number

The ratio by which to darken the colour, e.g. 0.2 would mean 20% darkening.

Return:

string

The darkened colour as hex string, e.g. '#FFFF00'.

Example:

let darker = darken('#ADD8E6', 0.2) // darken by 20%

public loadClusterLayer(geojsonPath: string): L.GeoJSON source

import {loadClusterLayer} from './layers/ClusterLayer.js'

Loads the given GeoJSON URL and returns a Leaflet GeoJSON layer that contains a child layer for each cluster.

Each cluster layer has an associated cluster label layer which is not part of the returned GeoJSON layer. Once the GeoJSON layer is added to a map, then the label layers are added to the same map as well, and removed again once the GeoJSON layer is removed. It is currently not possible to easily access the label layers programmatically after this function returns.

Params:

NameTypeAttributeDescription
geojsonPath string

The GeoJSON URL to load.

Return:

L.GeoJSON

The GeoJSON layer with all the clusters in it.

public loadCountryLayer(geojsonPath: string): L.GeoJSON source

import {loadCountryLayer} from './layers/CountryLayer.js'

Loads the given GeoJSON URL and returns a Leaflet GeoJSON layer that contains a child layer for each country.

Each country layer has an associated country label layer which is not part of the returned GeoJSON layer. Once the GeoJSON layer is added to a map, then the label layers are added to the same map as well, and removed again once the GeoJSON layer is removed. It is currently not possible to easily access the label layers programmatically after this function returns.

The returned GeoJSON layer listens for the following custom events:

  • fill/nofill - when received, enables/disables polygon filling
  • showmarkers/hidemarkers - when received, adds/removes all country labels

Params:

NameTypeAttributeDescription
geojsonPath string

The GeoJSON URL to load.

Return:

L.GeoJSON

The GeoJSON layer with all the countries in it.