File

libs/open-layers/src/lib/controls/legend/ol-layer-animate-time/ol-layer-animate-time.component.ts

Description

Legend component to animate time dependend layers, the time information is gathered by the WMS capabilities

Extends

OlLayerTimeSelectorComponent

Implements

OnInit

Metadata

selector n52-ol-layer-animate-time
templateUrl ./ol-layer-animate-time.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(wmsCaps: WmsCapabilitiesService)
Parameters :
Name Type Optional
wmsCaps WmsCapabilitiesService No

Inputs

timeInterval
Default value : 2000

Interval of the animation

layer
Type : BaseLayer

Methods

Public resetAnimation
resetAnimation()
Returns : void
Public startAnimation
startAnimation()
Returns : void
Public stopAnimation
stopAnimation()
Returns : void
Public compareFn
compareFn(option1: Date, option2: Date)
Parameters :
Name Type Optional
option1 Date No
option2 Date No
Returns : boolean
Protected determineCurrentTimeParameter
determineCurrentTimeParameter()
Returns : void
ngOnInit
ngOnInit()
Returns : void
Public onSelect
onSelect(time: Date)
Parameters :
Name Type Optional
time Date No
Returns : void
Protected setTime
setTime(time: Date)
Parameters :
Name Type Optional
time Date No
Returns : void

Properties

Private interval
Type : NodeJS.Timeout
Public currentTime
Type : Date
Protected layerid
Type : string
Protected layerSource
Type : TileWMS
Public loading
Type : boolean
Public timeDimensions
Type : Date[]
Protected url
Type : string
import { Component, Input, OnInit } from '@angular/core';

import { WmsCapabilitiesService } from '../../../services/wms-capabilities.service';
import { OlLayerTimeSelectorComponent } from '../ol-layer-time-selector/ol-layer-time-selector.component';

/**
 * Legend component to animate time dependend layers, the time information is gathered by the WMS capabilities
 */
@Component({
  selector: 'n52-ol-layer-animate-time',
  templateUrl: './ol-layer-animate-time.component.html'
})
export class OlLayerAnimateTimeComponent extends OlLayerTimeSelectorComponent implements OnInit {

  /**
   * Interval of the animation
   */
  @Input() timeInterval = 2000;

  private interval: NodeJS.Timeout;

  constructor(
    protected wmsCaps: WmsCapabilitiesService
  ) {
    super(wmsCaps);
  }

  public startAnimation() {
    // get current time parameter
    this.determineCurrentTimeParameter();
    // find index in list
    let idx = this.timeDimensions.findIndex(e => e.getTime() === this.currentTime.getTime());
    // start animation
    this.interval = setInterval(() => {
      idx++;
      if (idx >= this.timeDimensions.length) { idx = 0; }
      this.setTime(this.timeDimensions[idx]);
    }, this.timeInterval);
  }

  public stopAnimation() {
    clearInterval(this.interval);
  }

  public resetAnimation() {
    this.wmsCaps.getDefaultTimeDimension(this.layerid, this.url).subscribe(time => this.setTime(time));
  }

}
<span *ngIf="loading">loading ...</span>
<span *ngIf="!loading">
    <span>{{currentTime}}</span>
    <span (click)="startAnimation()"> start </span>
    <span (click)="stopAnimation()"> stop </span>
    <span (click)="resetAnimation()"> reset </span>
</span>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""