1 | "use strict";
|
2 | var core_1 = require('@angular/core');
|
3 | var circle_manager_1 = require('../services/managers/circle-manager');
|
4 | var SebmGoogleMapCircle = (function () {
|
5 | function SebmGoogleMapCircle(_manager) {
|
6 | this._manager = _manager;
|
7 | |
8 |
|
9 |
|
10 | this.clickable = true;
|
11 | |
12 |
|
13 |
|
14 | this.draggable = false;
|
15 | |
16 |
|
17 |
|
18 |
|
19 | this.editable = false;
|
20 | |
21 |
|
22 |
|
23 | this.radius = 0;
|
24 | |
25 |
|
26 |
|
27 |
|
28 | this.strokePosition = 'CENTER';
|
29 | |
30 |
|
31 |
|
32 | this.strokeWeight = 0;
|
33 | |
34 |
|
35 |
|
36 | this.visible = true;
|
37 | |
38 |
|
39 |
|
40 | this.centerChange = new core_1.EventEmitter();
|
41 | |
42 |
|
43 |
|
44 | this.circleClick = new core_1.EventEmitter();
|
45 | |
46 |
|
47 |
|
48 | this.circleDblClick = new core_1.EventEmitter();
|
49 | |
50 |
|
51 |
|
52 | this.drag = new core_1.EventEmitter();
|
53 | |
54 |
|
55 |
|
56 | this.dragEnd = new core_1.EventEmitter();
|
57 | |
58 |
|
59 |
|
60 | this.dragStart = new core_1.EventEmitter();
|
61 | |
62 |
|
63 |
|
64 | this.mouseDown = new core_1.EventEmitter();
|
65 | |
66 |
|
67 |
|
68 | this.mouseMove = new core_1.EventEmitter();
|
69 | |
70 |
|
71 |
|
72 | this.mouseOut = new core_1.EventEmitter();
|
73 | |
74 |
|
75 |
|
76 | this.mouseOver = new core_1.EventEmitter();
|
77 | |
78 |
|
79 |
|
80 | this.mouseUp = new core_1.EventEmitter();
|
81 | |
82 |
|
83 |
|
84 | this.radiusChange = new core_1.EventEmitter();
|
85 | |
86 |
|
87 |
|
88 | this.rightClick = new core_1.EventEmitter();
|
89 | this._circleAddedToManager = false;
|
90 | this._eventSubscriptions = [];
|
91 | }
|
92 |
|
93 | SebmGoogleMapCircle.prototype.ngOnInit = function () {
|
94 | this._manager.addCircle(this);
|
95 | this._circleAddedToManager = true;
|
96 | this._registerEventListeners();
|
97 | };
|
98 |
|
99 | SebmGoogleMapCircle.prototype.ngOnChanges = function (changes) {
|
100 | if (!this._circleAddedToManager) {
|
101 | return;
|
102 | }
|
103 | if (changes['latitude'] || changes['longitude']) {
|
104 | this._manager.setCenter(this);
|
105 | }
|
106 | if (changes['editable']) {
|
107 | this._manager.setEditable(this);
|
108 | }
|
109 | if (changes['draggable']) {
|
110 | this._manager.setDraggable(this);
|
111 | }
|
112 | if (changes['visible']) {
|
113 | this._manager.setVisible(this);
|
114 | }
|
115 | if (changes['radius']) {
|
116 | this._manager.setRadius(this);
|
117 | }
|
118 | this._updateCircleOptionsChanges(changes);
|
119 | };
|
120 | SebmGoogleMapCircle.prototype._updateCircleOptionsChanges = function (changes) {
|
121 | var options = {};
|
122 | var optionKeys = Object.keys(changes).filter(function (k) { return SebmGoogleMapCircle._mapOptions.indexOf(k) !== -1; });
|
123 | optionKeys.forEach(function (k) { options[k] = changes[k].currentValue; });
|
124 | if (optionKeys.length > 0) {
|
125 | this._manager.setOptions(this, options);
|
126 | }
|
127 | };
|
128 | SebmGoogleMapCircle.prototype._registerEventListeners = function () {
|
129 | var _this = this;
|
130 | var events = new Map();
|
131 | events.set('center_changed', this.centerChange);
|
132 | events.set('click', this.circleClick);
|
133 | events.set('dblclick', this.circleDblClick);
|
134 | events.set('drag', this.drag);
|
135 | events.set('dragend', this.dragEnd);
|
136 | events.set('dragStart', this.dragStart);
|
137 | events.set('mousedown', this.mouseDown);
|
138 | events.set('mousemove', this.mouseMove);
|
139 | events.set('mouseout', this.mouseOut);
|
140 | events.set('mouseover', this.mouseOver);
|
141 | events.set('mouseup', this.mouseUp);
|
142 | events.set('radius_changed', this.radiusChange);
|
143 | events.set('rightclick', this.rightClick);
|
144 | events.forEach(function (eventEmitter, eventName) {
|
145 | _this._eventSubscriptions.push(_this._manager.createEventObservable(eventName, _this).subscribe(function (value) {
|
146 | switch (eventName) {
|
147 | case 'radius_changed':
|
148 | _this._manager.getRadius(_this).then(function (radius) { return eventEmitter.emit(radius); });
|
149 | break;
|
150 | case 'center_changed':
|
151 | _this._manager.getCenter(_this).then(function (center) {
|
152 | return eventEmitter.emit({ lat: center.lat(), lng: center.lng() });
|
153 | });
|
154 | break;
|
155 | default:
|
156 | eventEmitter.emit({ coords: { lat: value.latLng.lat(), lng: value.latLng.lng() } });
|
157 | }
|
158 | }));
|
159 | });
|
160 | };
|
161 |
|
162 | SebmGoogleMapCircle.prototype.ngOnDestroy = function () {
|
163 | this._eventSubscriptions.forEach(function (s) { s.unsubscribe(); });
|
164 | this._eventSubscriptions = null;
|
165 | this._manager.removeCircle(this);
|
166 | };
|
167 | |
168 |
|
169 |
|
170 | SebmGoogleMapCircle.prototype.getBounds = function () { return this._manager.getBounds(this); };
|
171 | SebmGoogleMapCircle.prototype.getCenter = function () { return this._manager.getCenter(this); };
|
172 | SebmGoogleMapCircle._mapOptions = [
|
173 | 'fillColor', 'fillOpacity', 'strokeColor', 'strokeOpacity', 'strokePosition', 'strokeWeight',
|
174 | 'visible', 'zIndex'
|
175 | ];
|
176 | SebmGoogleMapCircle.decorators = [
|
177 | { type: core_1.Directive, args: [{
|
178 | selector: 'sebm-google-map-circle',
|
179 | inputs: [
|
180 | 'latitude', 'longitude', 'clickable', 'draggable: circleDraggable', 'editable', 'fillColor',
|
181 | 'fillOpacity', 'radius', 'strokeColor', 'strokeOpacity', 'strokePosition', 'strokeWeight',
|
182 | 'visible', 'zIndex'
|
183 | ],
|
184 | outputs: [
|
185 | 'centerChange', 'circleClick', 'circleDblClick', 'drag', 'dragEnd', 'dragStart', 'mouseDown',
|
186 | 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'radiusChange', 'rightClick'
|
187 | ]
|
188 | },] },
|
189 | ];
|
190 |
|
191 | SebmGoogleMapCircle.ctorParameters = function () { return [
|
192 | { type: circle_manager_1.CircleManager, },
|
193 | ]; };
|
194 | return SebmGoogleMapCircle;
|
195 | }());
|
196 | exports.SebmGoogleMapCircle = SebmGoogleMapCircle;
|
197 |
|
\ | No newline at end of file |