UNPKG

4.78 kBJavaScriptView Raw
1"use strict";
2var core_1 = require('@angular/core');
3var kml_layer_manager_1 = require('./../services/managers/kml-layer-manager');
4var layerId = 0;
5var SebmGoogleMapKmlLayer = (function () {
6 function SebmGoogleMapKmlLayer(_manager) {
7 this._manager = _manager;
8 this._addedToManager = false;
9 this._id = (layerId++).toString();
10 this._subscriptions = [];
11 /**
12 * If true, the layer receives mouse events. Default value is true.
13 */
14 this.clickable = true;
15 /**
16 * By default, the input map is centered and zoomed to the bounding box of the contents of the
17 * layer.
18 * If this option is set to true, the viewport is left unchanged, unless the map's center and zoom
19 * were never set.
20 */
21 this.preserveViewport = false;
22 /**
23 * Whether to render the screen overlays. Default true.
24 */
25 this.screenOverlays = true;
26 /**
27 * Suppress the rendering of info windows when layer features are clicked.
28 */
29 this.suppressInfoWindows = false;
30 /**
31 * The URL of the KML document to display.
32 */
33 this.url = null;
34 /**
35 * The z-index of the layer.
36 */
37 this.zIndex = null;
38 /**
39 * This event is fired when a feature in the layer is clicked.
40 */
41 this.layerClick = new core_1.EventEmitter();
42 /**
43 * This event is fired when the KML layers default viewport has changed.
44 */
45 this.defaultViewportChange = new core_1.EventEmitter();
46 /**
47 * This event is fired when the KML layer has finished loading.
48 * At this point it is safe to read the status property to determine if the layer loaded
49 * successfully.
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 /** @internal */
91 SebmGoogleMapKmlLayer.prototype.id = function () { return this._id; };
92 /** @internal */
93 SebmGoogleMapKmlLayer.prototype.toString = function () { return "SebmGoogleMapKmlLayer-" + this._id.toString(); };
94 /** @internal */
95 SebmGoogleMapKmlLayer.prototype.ngOnDestroy = function () {
96 this._manager.deleteKmlLayer(this);
97 // unsubscribe all registered observable subscriptions
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 /** @nocollapse */
109 SebmGoogleMapKmlLayer.ctorParameters = function () { return [
110 { type: kml_layer_manager_1.KmlLayerManager, },
111 ]; };
112 return SebmGoogleMapKmlLayer;
113}());
114exports.SebmGoogleMapKmlLayer = SebmGoogleMapKmlLayer;
115//# sourceMappingURL=google-map-kml-layer.js.map
\No newline at end of file