@geosdi/ngx-leaflet-timedimension-plugin
v1.1.2
Published
Service to add timedimension to map
Downloads
4
Maintainers
Readme
NgxLeafletTimedimensionPlugin
This library was generated with Angular CLI version 13.0.0.
General information
Service to wrap leaflet timedimensione see documentation to https://github.com/socib/Leaflet.TimeDimension
Installation
npm i @geosdi/ngx-leaflet-timedimension-plugin --save
It depends on :
"@angular/common": ">=13.0.0",
"@angular/core": ">=13.0.0",
"leaflet": ">=1.7.1",
"leaflet-timedimension": "^1.1.1"
Usage
import { Injectable } from '@angular/core';
import {TimeDimensionExtensionService} from "./time-dimension-extension-service";
@Injectable({
providedIn: 'root'
})
export class Service {
constructor(private ngxLeafletTimedimensionPluginService: TimeDimensionExtensionService) {
}
public addPlugin() {
//4/11/2021
const endTime = new Date(1636022400000);
//28/10/2021
const startTime = new Date(1636022400000 - 604800000);
this.ngxLeafletTimedimensionPluginService
.withTimeDimensionOptionsOptions({
times: L.TimeDimension.Util.explodeTimeRange(startTime, endTime, "PT5M"),
period: "P5M",
})
.withMap(this.map).withPlayerOptions({loop: true, transitionTime: 333}).applyTimeDimensionPlugin();
this.ngxLeafletTimedimensionPluginService.setPlayerToLoop(true);
wmsLayer.addTo(this.map);
setTimeout(() => {
this.ngxLeafletTimedimensionPluginService.setPlayerToLoop(false);
}, 2000);
}
}