UNPKG

1.82 kBTypeScriptView Raw
1import { DoCheck, IterableDiffer, IterableDiffers, NgZone, OnDestroy, OnInit } from '@angular/core';
2import { Layer } from 'leaflet';
3import { LeafletDirective } from '../core/leaflet.directive';
4/**
5 * Layers directive
6 *
7 * This directive is used to directly control map layers. As changes are made to the input array of
8 * layers, the map is synched to the array. As layers are added or removed from the input array, they
9 * are also added or removed from the map. The input array is treated as immutable. To detect changes,
10 * you must change the array instance.
11 *
12 * Important Note: The input layers array is assumed to be immutable. This means you need to use an
13 * immutable array implementation or create a new copy of your array when you make changes, otherwise
14 * this directive won't detect the change. This is by design. It's for performance reasons. Change
15 * detection of mutable arrays requires diffing the state of the array on every DoCheck cycle, which
16 * is extremely expensive from a time complexity perspective.
17 *
18 */
19export declare class LeafletLayersDirective implements DoCheck, OnDestroy, OnInit {
20 private differs;
21 private zone;
22 layersValue: Layer[];
23 layersDiffer: IterableDiffer<Layer>;
24 set layers(v: Layer[]);
25 get layers(): Layer[];
26 private leafletDirective;
27 constructor(leafletDirective: LeafletDirective, differs: IterableDiffers, zone: NgZone);
28 ngDoCheck(): void;
29 ngOnInit(): void;
30 ngOnDestroy(): void;
31 /**
32 * Update the state of the layers.
33 * We use an iterable differ to synchronize the map layers with the state of the bound layers array.
34 * This is important because it allows us to react to changes to the contents of the array as well
35 * as changes to the actual array instance.
36 */
37 private updateLayers;
38}