1 | "use strict";
|
2 | var core_1 = require('@angular/core');
|
3 | var polyline_manager_1 = require('../services/managers/polyline-manager');
|
4 | var google_map_polyline_point_1 = require('./google-map-polyline-point');
|
5 | var polylineId = 0;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | var SebmGoogleMapPolyline = (function () {
|
37 | function SebmGoogleMapPolyline(_polylineManager) {
|
38 | this._polylineManager = _polylineManager;
|
39 | |
40 |
|
41 |
|
42 | this.clickable = true;
|
43 | |
44 |
|
45 |
|
46 |
|
47 | this.draggable = false;
|
48 | |
49 |
|
50 |
|
51 |
|
52 | this.editable = false;
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | this.geodesic = false;
|
60 | |
61 |
|
62 |
|
63 | this.visible = true;
|
64 | |
65 |
|
66 |
|
67 | this.lineClick = new core_1.EventEmitter();
|
68 | |
69 |
|
70 |
|
71 | this.lineDblClick = new core_1.EventEmitter();
|
72 | |
73 |
|
74 |
|
75 | this.lineDrag = new core_1.EventEmitter();
|
76 | |
77 |
|
78 |
|
79 | this.lineDragEnd = new core_1.EventEmitter();
|
80 | |
81 |
|
82 |
|
83 | this.lineDragStart = new core_1.EventEmitter();
|
84 | |
85 |
|
86 |
|
87 | this.lineMouseDown = new core_1.EventEmitter();
|
88 | |
89 |
|
90 |
|
91 | this.lineMouseMove = new core_1.EventEmitter();
|
92 | |
93 |
|
94 |
|
95 | this.lineMouseOut = new core_1.EventEmitter();
|
96 | |
97 |
|
98 |
|
99 | this.lineMouseOver = new core_1.EventEmitter();
|
100 | |
101 |
|
102 |
|
103 | this.lineMouseUp = new core_1.EventEmitter();
|
104 | |
105 |
|
106 |
|
107 | this.lineRightClick = new core_1.EventEmitter();
|
108 | this._polylineAddedToManager = false;
|
109 | this._subscriptions = [];
|
110 | this._id = (polylineId++).toString();
|
111 | }
|
112 |
|
113 | SebmGoogleMapPolyline.prototype.ngAfterContentInit = function () {
|
114 | var _this = this;
|
115 | if (this.points.length) {
|
116 | this.points.forEach(function (point) {
|
117 | var s = point.positionChanged.subscribe(function () { _this._polylineManager.updatePolylinePoints(_this); });
|
118 | _this._subscriptions.push(s);
|
119 | });
|
120 | }
|
121 | if (!this._polylineAddedToManager) {
|
122 | this._init();
|
123 | }
|
124 | var s = this.points.changes.subscribe(function () { return _this._polylineManager.updatePolylinePoints(_this); });
|
125 | this._subscriptions.push(s);
|
126 | this._polylineManager.updatePolylinePoints(this);
|
127 | };
|
128 | SebmGoogleMapPolyline.prototype.ngOnChanges = function (changes) {
|
129 | if (!this._polylineAddedToManager) {
|
130 | this._init();
|
131 | return;
|
132 | }
|
133 | var options = {};
|
134 | var optionKeys = Object.keys(changes).filter(function (k) { return SebmGoogleMapPolyline._polylineOptionsAttributes.indexOf(k) !== -1; });
|
135 | optionKeys.forEach(function (k) { return options[k] = changes[k].currentValue; });
|
136 | this._polylineManager.setPolylineOptions(this, options);
|
137 | };
|
138 | SebmGoogleMapPolyline.prototype._init = function () {
|
139 | this._polylineManager.addPolyline(this);
|
140 | this._polylineAddedToManager = true;
|
141 | this._addEventListeners();
|
142 | };
|
143 | SebmGoogleMapPolyline.prototype._addEventListeners = function () {
|
144 | var _this = this;
|
145 | var handlers = [
|
146 | { name: 'click', handler: function (ev) { return _this.lineClick.emit(ev); } },
|
147 | { name: 'dbclick', handler: function (ev) { return _this.lineDblClick.emit(ev); } },
|
148 | { name: 'drag', handler: function (ev) { return _this.lineDrag.emit(ev); } },
|
149 | { name: 'dragend', handler: function (ev) { return _this.lineDragEnd.emit(ev); } },
|
150 | { name: 'dragstart', handler: function (ev) { return _this.lineDragStart.emit(ev); } },
|
151 | { name: 'mousedown', handler: function (ev) { return _this.lineMouseDown.emit(ev); } },
|
152 | { name: 'mousemove', handler: function (ev) { return _this.lineMouseMove.emit(ev); } },
|
153 | { name: 'mouseout', handler: function (ev) { return _this.lineMouseOut.emit(ev); } },
|
154 | { name: 'mouseover', handler: function (ev) { return _this.lineMouseOver.emit(ev); } },
|
155 | { name: 'mouseup', handler: function (ev) { return _this.lineMouseUp.emit(ev); } },
|
156 | { name: 'rightclick', handler: function (ev) { return _this.lineRightClick.emit(ev); } },
|
157 | ];
|
158 | handlers.forEach(function (obj) {
|
159 | var os = _this._polylineManager.createEventObservable(obj.name, _this).subscribe(obj.handler);
|
160 | _this._subscriptions.push(os);
|
161 | });
|
162 | };
|
163 |
|
164 | SebmGoogleMapPolyline.prototype._getPoints = function () {
|
165 | if (this.points) {
|
166 | return this.points.toArray();
|
167 | }
|
168 | return [];
|
169 | };
|
170 |
|
171 | SebmGoogleMapPolyline.prototype.id = function () { return this._id; };
|
172 |
|
173 | SebmGoogleMapPolyline.prototype.ngOnDestroy = function () {
|
174 | this._polylineManager.deletePolyline(this);
|
175 |
|
176 | this._subscriptions.forEach(function (s) { return s.unsubscribe(); });
|
177 | };
|
178 | SebmGoogleMapPolyline._polylineOptionsAttributes = [
|
179 | 'draggable', 'editable', 'visible', 'geodesic', 'strokeColor', 'strokeOpacity', 'strokeWeight',
|
180 | 'zIndex'
|
181 | ];
|
182 | SebmGoogleMapPolyline.decorators = [
|
183 | { type: core_1.Directive, args: [{
|
184 | selector: 'sebm-google-map-polyline',
|
185 | inputs: [
|
186 | 'clickable', 'draggable: polylineDraggable', 'editable', 'geodesic', 'strokeColor',
|
187 | 'strokeWeight', 'strokeOpacity', 'visible', 'zIndex'
|
188 | ],
|
189 | outputs: [
|
190 | 'lineClick', 'lineDblClick', 'lineDrag', 'lineDragEnd', 'lineMouseDown', 'lineMouseMove',
|
191 | 'lineMouseOut', 'lineMouseOver', 'lineMouseUp', 'lineRightClick'
|
192 | ]
|
193 | },] },
|
194 | ];
|
195 |
|
196 | SebmGoogleMapPolyline.ctorParameters = function () { return [
|
197 | { type: polyline_manager_1.PolylineManager, },
|
198 | ]; };
|
199 | SebmGoogleMapPolyline.propDecorators = {
|
200 | 'points': [{ type: core_1.ContentChildren, args: [google_map_polyline_point_1.SebmGoogleMapPolylinePoint,] },],
|
201 | };
|
202 | return SebmGoogleMapPolyline;
|
203 | }());
|
204 | exports.SebmGoogleMapPolyline = SebmGoogleMapPolyline;
|
205 |
|
\ | No newline at end of file |