1 | "use strict";
|
2 | var core_1 = require('@angular/core');
|
3 | var marker_manager_1 = require('../services/managers/marker-manager');
|
4 | var google_map_info_window_1 = require('./google-map-info-window');
|
5 | var markerId = 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 | var SebmGoogleMapMarker = (function () {
|
32 | function SebmGoogleMapMarker(_markerManager) {
|
33 | this._markerManager = _markerManager;
|
34 | |
35 |
|
36 |
|
37 | this.draggable = false;
|
38 | |
39 |
|
40 |
|
41 | this.visible = true;
|
42 | |
43 |
|
44 |
|
45 | this.openInfoWindow = true;
|
46 | |
47 |
|
48 |
|
49 | this.opacity = 1;
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | this.zIndex = 1;
|
57 | |
58 |
|
59 |
|
60 | this.markerClick = new core_1.EventEmitter();
|
61 | |
62 |
|
63 |
|
64 | this.dragEnd = new core_1.EventEmitter();
|
65 | |
66 |
|
67 |
|
68 | this.mouseOver = new core_1.EventEmitter();
|
69 | |
70 |
|
71 |
|
72 | this.mouseOut = new core_1.EventEmitter();
|
73 | this._markerAddedToManger = false;
|
74 | this._observableSubscriptions = [];
|
75 | this._id = (markerId++).toString();
|
76 | }
|
77 |
|
78 | SebmGoogleMapMarker.prototype.ngAfterContentInit = function () {
|
79 | if (this.infoWindow != null) {
|
80 | this.infoWindow.hostMarker = this;
|
81 | }
|
82 | };
|
83 |
|
84 | SebmGoogleMapMarker.prototype.ngOnChanges = function (changes) {
|
85 | if (typeof this.latitude !== 'number' || typeof this.longitude !== 'number') {
|
86 | return;
|
87 | }
|
88 | if (!this._markerAddedToManger) {
|
89 | this._markerManager.addMarker(this);
|
90 | this._markerAddedToManger = true;
|
91 | this._addEventListeners();
|
92 | return;
|
93 | }
|
94 | if (changes['latitude'] || changes['longitude']) {
|
95 | this._markerManager.updateMarkerPosition(this);
|
96 | }
|
97 | if (changes['title']) {
|
98 | this._markerManager.updateTitle(this);
|
99 | }
|
100 | if (changes['label']) {
|
101 | this._markerManager.updateLabel(this);
|
102 | }
|
103 | if (changes['draggable']) {
|
104 | this._markerManager.updateDraggable(this);
|
105 | }
|
106 | if (changes['iconUrl']) {
|
107 | this._markerManager.updateIcon(this);
|
108 | }
|
109 | if (changes['opacity']) {
|
110 | this._markerManager.updateOpacity(this);
|
111 | }
|
112 | if (changes['visible']) {
|
113 | this._markerManager.updateVisible(this);
|
114 | }
|
115 | if (changes['zIndex']) {
|
116 | this._markerManager.updateZIndex(this);
|
117 | }
|
118 | };
|
119 | SebmGoogleMapMarker.prototype._addEventListeners = function () {
|
120 | var _this = this;
|
121 | var cs = this._markerManager.createEventObservable('click', this).subscribe(function () {
|
122 | if (_this.openInfoWindow && _this.infoWindow != null) {
|
123 | _this.infoWindow.open();
|
124 | }
|
125 | _this.markerClick.emit(null);
|
126 | });
|
127 | this._observableSubscriptions.push(cs);
|
128 | var ds = this._markerManager.createEventObservable('dragend', this)
|
129 | .subscribe(function (e) {
|
130 | _this.dragEnd.emit({ coords: { lat: e.latLng.lat(), lng: e.latLng.lng() } });
|
131 | });
|
132 | this._observableSubscriptions.push(ds);
|
133 | var mover = this._markerManager.createEventObservable('mouseover', this)
|
134 | .subscribe(function (e) {
|
135 | _this.mouseOver.emit({ coords: { lat: e.latLng.lat(), lng: e.latLng.lng() } });
|
136 | });
|
137 | this._observableSubscriptions.push(mover);
|
138 | var mout = this._markerManager.createEventObservable('mouseout', this)
|
139 | .subscribe(function (e) {
|
140 | _this.mouseOut.emit({ coords: { lat: e.latLng.lat(), lng: e.latLng.lng() } });
|
141 | });
|
142 | this._observableSubscriptions.push(mout);
|
143 | };
|
144 |
|
145 | SebmGoogleMapMarker.prototype.id = function () { return this._id; };
|
146 |
|
147 | SebmGoogleMapMarker.prototype.toString = function () { return 'SebmGoogleMapMarker-' + this._id.toString(); };
|
148 |
|
149 | SebmGoogleMapMarker.prototype.ngOnDestroy = function () {
|
150 | this._markerManager.deleteMarker(this);
|
151 |
|
152 | this._observableSubscriptions.forEach(function (s) { return s.unsubscribe(); });
|
153 | };
|
154 | SebmGoogleMapMarker.decorators = [
|
155 | { type: core_1.Directive, args: [{
|
156 | selector: 'sebm-google-map-marker',
|
157 | inputs: [
|
158 | 'latitude', 'longitude', 'title', 'label', 'draggable: markerDraggable', 'iconUrl',
|
159 | 'openInfoWindow', 'opacity', 'visible', 'zIndex'
|
160 | ],
|
161 | outputs: ['markerClick', 'dragEnd', 'mouseOver', 'mouseOut']
|
162 | },] },
|
163 | ];
|
164 |
|
165 | SebmGoogleMapMarker.ctorParameters = function () { return [
|
166 | { type: marker_manager_1.MarkerManager, },
|
167 | ]; };
|
168 | SebmGoogleMapMarker.propDecorators = {
|
169 | 'infoWindow': [{ type: core_1.ContentChild, args: [google_map_info_window_1.SebmGoogleMapInfoWindow,] },],
|
170 | };
|
171 | return SebmGoogleMapMarker;
|
172 | }());
|
173 | exports.SebmGoogleMapMarker = SebmGoogleMapMarker;
|
174 |
|
\ | No newline at end of file |