UNPKG

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