1 | "use strict";
|
2 | var core_1 = require('@angular/core');
|
3 | var kml_layer_manager_1 = require('./../services/managers/kml-layer-manager');
|
4 | var layerId = 0;
|
5 | var SebmGoogleMapKmlLayer = (function () {
|
6 | function SebmGoogleMapKmlLayer(_manager) {
|
7 | this._manager = _manager;
|
8 | this._addedToManager = false;
|
9 | this._id = (layerId++).toString();
|
10 | this._subscriptions = [];
|
11 | |
12 |
|
13 |
|
14 | this.clickable = true;
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | this.preserveViewport = false;
|
22 | |
23 |
|
24 |
|
25 | this.screenOverlays = true;
|
26 | |
27 |
|
28 |
|
29 | this.suppressInfoWindows = false;
|
30 | |
31 |
|
32 |
|
33 | this.url = null;
|
34 | |
35 |
|
36 |
|
37 | this.zIndex = null;
|
38 | |
39 |
|
40 |
|
41 | this.layerClick = new core_1.EventEmitter();
|
42 | |
43 |
|
44 |
|
45 | this.defaultViewportChange = new core_1.EventEmitter();
|
46 | |
47 |
|
48 |
|
49 |
|
50 |
|
51 | this.statusChange = new core_1.EventEmitter();
|
52 | }
|
53 | SebmGoogleMapKmlLayer.prototype.ngOnInit = function () {
|
54 | if (this._addedToManager) {
|
55 | return;
|
56 | }
|
57 | this._manager.addKmlLayer(this);
|
58 | this._addedToManager = true;
|
59 | this._addEventListeners();
|
60 | };
|
61 | SebmGoogleMapKmlLayer.prototype.ngOnChanges = function (changes) {
|
62 | if (!this._addedToManager) {
|
63 | return;
|
64 | }
|
65 | this._updatePolygonOptions(changes);
|
66 | };
|
67 | SebmGoogleMapKmlLayer.prototype._updatePolygonOptions = function (changes) {
|
68 | var options = Object.keys(changes)
|
69 | .filter(function (k) { return SebmGoogleMapKmlLayer._kmlLayerOptions.indexOf(k) !== -1; })
|
70 | .reduce(function (obj, k) {
|
71 | obj[k] = changes[k].currentValue;
|
72 | return obj;
|
73 | }, {});
|
74 | if (Object.keys(options).length > 0) {
|
75 | this._manager.setOptions(this, options);
|
76 | }
|
77 | };
|
78 | SebmGoogleMapKmlLayer.prototype._addEventListeners = function () {
|
79 | var _this = this;
|
80 | var listeners = [
|
81 | { name: 'click', handler: function (ev) { return _this.layerClick.emit(ev); } },
|
82 | { name: 'defaultviewport_changed', handler: function () { return _this.defaultViewportChange.emit(); } },
|
83 | { name: 'status_changed', handler: function () { return _this.statusChange.emit(); } },
|
84 | ];
|
85 | listeners.forEach(function (obj) {
|
86 | var os = _this._manager.createEventObservable(obj.name, _this).subscribe(obj.handler);
|
87 | _this._subscriptions.push(os);
|
88 | });
|
89 | };
|
90 |
|
91 | SebmGoogleMapKmlLayer.prototype.id = function () { return this._id; };
|
92 |
|
93 | SebmGoogleMapKmlLayer.prototype.toString = function () { return "SebmGoogleMapKmlLayer-" + this._id.toString(); };
|
94 |
|
95 | SebmGoogleMapKmlLayer.prototype.ngOnDestroy = function () {
|
96 | this._manager.deleteKmlLayer(this);
|
97 |
|
98 | this._subscriptions.forEach(function (s) { return s.unsubscribe(); });
|
99 | };
|
100 | SebmGoogleMapKmlLayer._kmlLayerOptions = ['clickable', 'preserveViewport', 'screenOverlays', 'suppressInfoWindows', 'url', 'zIndex'];
|
101 | SebmGoogleMapKmlLayer.decorators = [
|
102 | { type: core_1.Directive, args: [{
|
103 | selector: 'sebm-google-map-kml-layer',
|
104 | inputs: ['clickable', 'preserveViewport', 'screenOverlays', 'suppressInfoWindows', 'url', 'zIndex'],
|
105 | outputs: ['layerClick', 'defaultViewportChange', 'statusChange']
|
106 | },] },
|
107 | ];
|
108 |
|
109 | SebmGoogleMapKmlLayer.ctorParameters = function () { return [
|
110 | { type: kml_layer_manager_1.KmlLayerManager, },
|
111 | ]; };
|
112 | return SebmGoogleMapKmlLayer;
|
113 | }());
|
114 | exports.SebmGoogleMapKmlLayer = SebmGoogleMapKmlLayer;
|
115 |
|
\ | No newline at end of file |