Home Reference Source Repository
import {TimeAxis} from 'leaflet-coverage/'
public class | source

TimeAxis

Mixin Extends:

L.Control, EventMixin

Displays a simple date/time picker for a coverage data layer by grouping time steps into dates and times.

Example:

Coverage data layer
new C.TimeAxis(covLayer).addTo(map)
// Selecting a date/time automatically sets the 'time' property in the layer.
// Similarly, when the layer fires an 'axisChange' event with {axis: 'time'}
// the control reflects that change.
Fake layer
var times = ['2000-01-01T00:00:00Z','2000-01-01T05:00:00Z'].map(s => new Date(s))
var fakeLayer = {
  timeSlices: times,
  time: times[1] // select the second time step initially
}
var timeAxis = new C.TimeAxis(fakeLayer).addTo(map)

// change the time and trigger a manual update
fakeLayer.time = times[0]
timeAxis.update()

Constructor Summary

Public Constructor
public

constructor(covLayer: object, options: object)

Creates a time axis control.

Method Summary

Public Methods
public

update()

Triggers a manual update of the date/time picker based on the time property of the layer.

Public Constructors

public constructor(covLayer: object, options: object) source

Creates a time axis control.

Params:

NameTypeAttributeDescription
covLayer object

The coverage data layer, or any object with timeSlices and time properties. If the object has on/off methods, then the control will listen for axisChange events with {axis: 'time'} and update itself automatically. If the layer fires a remove event, then the control will remove itself from the map.

options object
  • optional

Control options.

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

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

options.title string
  • optional
  • default: 'Time'

The label to show above the date/time picker.

options.templateId string
  • optional

Element ID of an alternative HTML <template> element to use.

Public Methods

public update() source

Triggers a manual update of the date/time picker based on the time property of the layer.

Useful if the supplied coverage data layer is not a real layer and won't fire the necessary events for automatic updates.