@inlog/inlog-maps 6.0.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/lib/index.d.ts +46 -0
  2. package/lib/index.js +47 -0
  3. package/lib/index.js.map +1 -0
  4. package/lib/map.d.ts +519 -0
  5. package/lib/map.js +1137 -0
  6. package/lib/map.js.map +1 -0
  7. package/lib/models/apis/google/google-circles.d.ts +18 -0
  8. package/lib/models/apis/google/google-circles.js +134 -0
  9. package/lib/models/apis/google/google-circles.js.map +1 -0
  10. package/lib/models/apis/google/google-geojson.d.ts +9 -0
  11. package/lib/models/apis/google/google-geojson.js +73 -0
  12. package/lib/models/apis/google/google-geojson.js.map +1 -0
  13. package/lib/models/apis/google/google-map.d.ts +16 -0
  14. package/lib/models/apis/google/google-map.js +174 -0
  15. package/lib/models/apis/google/google-map.js.map +1 -0
  16. package/lib/models/apis/google/google-markers.d.ts +29 -0
  17. package/lib/models/apis/google/google-markers.js +325 -0
  18. package/lib/models/apis/google/google-markers.js.map +1 -0
  19. package/lib/models/apis/google/google-overlay.d.ts +11 -0
  20. package/lib/models/apis/google/google-overlay.js +102 -0
  21. package/lib/models/apis/google/google-overlay.js.map +1 -0
  22. package/lib/models/apis/google/google-polygons.d.ts +29 -0
  23. package/lib/models/apis/google/google-polygons.js +301 -0
  24. package/lib/models/apis/google/google-polygons.js.map +1 -0
  25. package/lib/models/apis/google/google-polylines.d.ts +55 -0
  26. package/lib/models/apis/google/google-polylines.js +707 -0
  27. package/lib/models/apis/google/google-polylines.js.map +1 -0
  28. package/lib/models/apis/google/google-popup.d.ts +10 -0
  29. package/lib/models/apis/google/google-popup.js +59 -0
  30. package/lib/models/apis/google/google-popup.js.map +1 -0
  31. package/lib/models/apis/googleMaps.d.ts +97 -0
  32. package/lib/models/apis/googleMaps.js +449 -0
  33. package/lib/models/apis/googleMaps.js.map +1 -0
  34. package/lib/models/apis/leaflet/leaflet-circle.d.ts +18 -0
  35. package/lib/models/apis/leaflet/leaflet-circle.js +163 -0
  36. package/lib/models/apis/leaflet/leaflet-circle.js.map +1 -0
  37. package/lib/models/apis/leaflet/leaflet-geojson.d.ts +9 -0
  38. package/lib/models/apis/leaflet/leaflet-geojson.js +73 -0
  39. package/lib/models/apis/leaflet/leaflet-geojson.js.map +1 -0
  40. package/lib/models/apis/leaflet/leaflet-map.d.ts +16 -0
  41. package/lib/models/apis/leaflet/leaflet-map.js +140 -0
  42. package/lib/models/apis/leaflet/leaflet-map.js.map +1 -0
  43. package/lib/models/apis/leaflet/leaflet-markers.d.ts +29 -0
  44. package/lib/models/apis/leaflet/leaflet-markers.js +294 -0
  45. package/lib/models/apis/leaflet/leaflet-markers.js.map +1 -0
  46. package/lib/models/apis/leaflet/leaflet-overlay.d.ts +10 -0
  47. package/lib/models/apis/leaflet/leaflet-overlay.js +35 -0
  48. package/lib/models/apis/leaflet/leaflet-overlay.js.map +1 -0
  49. package/lib/models/apis/leaflet/leaflet-polygons.d.ts +23 -0
  50. package/lib/models/apis/leaflet/leaflet-polygons.js +211 -0
  51. package/lib/models/apis/leaflet/leaflet-polygons.js.map +1 -0
  52. package/lib/models/apis/leaflet/leaflet-polylines.d.ts +54 -0
  53. package/lib/models/apis/leaflet/leaflet-polylines.js +706 -0
  54. package/lib/models/apis/leaflet/leaflet-polylines.js.map +1 -0
  55. package/lib/models/apis/leaflet/leaflet-popup.d.ts +11 -0
  56. package/lib/models/apis/leaflet/leaflet-popup.js +74 -0
  57. package/lib/models/apis/leaflet/leaflet-popup.js.map +1 -0
  58. package/lib/models/apis/leaflet.d.ts +99 -0
  59. package/lib/models/apis/leaflet.js +464 -0
  60. package/lib/models/apis/leaflet.js.map +1 -0
  61. package/lib/models/apis/mapFunctions.d.ts +85 -0
  62. package/lib/models/apis/mapFunctions.js +2 -0
  63. package/lib/models/apis/mapFunctions.js.map +1 -0
  64. package/lib/models/dto/event-type.d.ts +33 -0
  65. package/lib/models/dto/event-type.js +39 -0
  66. package/lib/models/dto/event-type.js.map +1 -0
  67. package/lib/models/dto/map-type.d.ts +4 -0
  68. package/lib/models/dto/map-type.js +6 -0
  69. package/lib/models/dto/map-type.js.map +1 -0
  70. package/lib/models/dto/polyline-type.d.ts +5 -0
  71. package/lib/models/dto/polyline-type.js +7 -0
  72. package/lib/models/dto/polyline-type.js.map +1 -0
  73. package/lib/models/features/circle/circle-alter-options.d.ts +12 -0
  74. package/lib/models/features/circle/circle-alter-options.js +14 -0
  75. package/lib/models/features/circle/circle-alter-options.js.map +1 -0
  76. package/lib/models/features/circle/circle-options.d.ts +15 -0
  77. package/lib/models/features/circle/circle-options.js +19 -0
  78. package/lib/models/features/circle/circle-options.js.map +1 -0
  79. package/lib/models/features/events/event-return.d.ts +4 -0
  80. package/lib/models/features/events/event-return.js +8 -0
  81. package/lib/models/features/events/event-return.js.map +1 -0
  82. package/lib/models/features/geojson/geojson-options.d.ts +5 -0
  83. package/lib/models/features/geojson/geojson-options.js +9 -0
  84. package/lib/models/features/geojson/geojson-options.js.map +1 -0
  85. package/lib/models/features/marker/circle-marker-options.d.ts +9 -0
  86. package/lib/models/features/marker/circle-marker-options.js +12 -0
  87. package/lib/models/features/marker/circle-marker-options.js.map +1 -0
  88. package/lib/models/features/marker/circle-marker-style.d.ts +8 -0
  89. package/lib/models/features/marker/circle-marker-style.js +12 -0
  90. package/lib/models/features/marker/circle-marker-style.js.map +1 -0
  91. package/lib/models/features/marker/marker-alter-options.d.ts +8 -0
  92. package/lib/models/features/marker/marker-alter-options.js +10 -0
  93. package/lib/models/features/marker/marker-alter-options.js.map +1 -0
  94. package/lib/models/features/marker/marker-icon.d.ts +6 -0
  95. package/lib/models/features/marker/marker-icon.js +10 -0
  96. package/lib/models/features/marker/marker-icon.js.map +1 -0
  97. package/lib/models/features/marker/marker-options.d.ts +11 -0
  98. package/lib/models/features/marker/marker-options.js +18 -0
  99. package/lib/models/features/marker/marker-options.js.map +1 -0
  100. package/lib/models/features/marker-clusterer/marker-clusterer-config.d.ts +6 -0
  101. package/lib/models/features/marker-clusterer/marker-clusterer-config.js +10 -0
  102. package/lib/models/features/marker-clusterer/marker-clusterer-config.js.map +1 -0
  103. package/lib/models/features/overlay/overlay-options.d.ts +11 -0
  104. package/lib/models/features/overlay/overlay-options.js +15 -0
  105. package/lib/models/features/overlay/overlay-options.js.map +1 -0
  106. package/lib/models/features/polygons/polygon-alter-options.d.ts +13 -0
  107. package/lib/models/features/polygons/polygon-alter-options.js +14 -0
  108. package/lib/models/features/polygons/polygon-alter-options.js.map +1 -0
  109. package/lib/models/features/polygons/polygon-options.d.ts +15 -0
  110. package/lib/models/features/polygons/polygon-options.js +19 -0
  111. package/lib/models/features/polygons/polygon-options.js.map +1 -0
  112. package/lib/models/features/polyline/navigations-options.d.ts +11 -0
  113. package/lib/models/features/polyline/navigations-options.js +16 -0
  114. package/lib/models/features/polyline/navigations-options.js.map +1 -0
  115. package/lib/models/features/polyline/polyline-options.d.ts +18 -0
  116. package/lib/models/features/polyline/polyline-options.js +20 -0
  117. package/lib/models/features/polyline/polyline-options.js.map +1 -0
  118. package/lib/models/features/popup/popup-options.d.ts +9 -0
  119. package/lib/models/features/popup/popup-options.js +13 -0
  120. package/lib/models/features/popup/popup-options.js.map +1 -0
  121. package/lib/utils/maps-api-loader.service.d.ts +14 -0
  122. package/lib/utils/maps-api-loader.service.js +89 -0
  123. package/lib/utils/maps-api-loader.service.js.map +1 -0
  124. package/lib/utils/url-builder.d.ts +20 -0
  125. package/lib/utils/url-builder.js +44 -0
  126. package/lib/utils/url-builder.js.map +1 -0
  127. package/lib-esm/index.d.ts +46 -0
  128. package/lib-esm/map.d.ts +519 -0
  129. package/lib-esm/models/apis/google/google-circles.d.ts +18 -0
  130. package/lib-esm/models/apis/google/google-geojson.d.ts +9 -0
  131. package/lib-esm/models/apis/google/google-map.d.ts +16 -0
  132. package/lib-esm/models/apis/google/google-markers.d.ts +29 -0
  133. package/lib-esm/models/apis/google/google-overlay.d.ts +11 -0
  134. package/lib-esm/models/apis/google/google-polygons.d.ts +29 -0
  135. package/lib-esm/models/apis/google/google-polylines.d.ts +55 -0
  136. package/lib-esm/models/apis/google/google-popup.d.ts +10 -0
  137. package/lib-esm/models/apis/googleMaps.d.ts +97 -0
  138. package/lib-esm/models/apis/leaflet/leaflet-circle.d.ts +18 -0
  139. package/lib-esm/models/apis/leaflet/leaflet-geojson.d.ts +9 -0
  140. package/lib-esm/models/apis/leaflet/leaflet-map.d.ts +16 -0
  141. package/lib-esm/models/apis/leaflet/leaflet-markers.d.ts +29 -0
  142. package/lib-esm/models/apis/leaflet/leaflet-overlay.d.ts +10 -0
  143. package/lib-esm/models/apis/leaflet/leaflet-polygons.d.ts +23 -0
  144. package/lib-esm/models/apis/leaflet/leaflet-polylines.d.ts +54 -0
  145. package/lib-esm/models/apis/leaflet/leaflet-popup.d.ts +11 -0
  146. package/lib-esm/models/apis/leaflet.d.ts +99 -0
  147. package/lib-esm/models/apis/mapFunctions.d.ts +85 -0
  148. package/lib-esm/models/dto/event-type.d.ts +33 -0
  149. package/lib-esm/models/dto/map-type.d.ts +4 -0
  150. package/lib-esm/models/dto/polyline-type.d.ts +5 -0
  151. package/lib-esm/models/features/circle/circle-alter-options.d.ts +12 -0
  152. package/lib-esm/models/features/circle/circle-options.d.ts +15 -0
  153. package/lib-esm/models/features/events/event-return.d.ts +4 -0
  154. package/lib-esm/models/features/geojson/geojson-options.d.ts +5 -0
  155. package/lib-esm/models/features/marker/circle-marker-options.d.ts +9 -0
  156. package/lib-esm/models/features/marker/circle-marker-style.d.ts +8 -0
  157. package/lib-esm/models/features/marker/marker-alter-options.d.ts +8 -0
  158. package/lib-esm/models/features/marker/marker-icon.d.ts +6 -0
  159. package/lib-esm/models/features/marker/marker-options.d.ts +11 -0
  160. package/lib-esm/models/features/marker-clusterer/marker-clusterer-config.d.ts +6 -0
  161. package/lib-esm/models/features/overlay/overlay-options.d.ts +11 -0
  162. package/lib-esm/models/features/polygons/polygon-alter-options.d.ts +13 -0
  163. package/lib-esm/models/features/polygons/polygon-options.d.ts +15 -0
  164. package/lib-esm/models/features/polyline/navigations-options.d.ts +11 -0
  165. package/lib-esm/models/features/polyline/polyline-options.d.ts +18 -0
  166. package/lib-esm/models/features/popup/popup-options.d.ts +9 -0
  167. package/lib-esm/utils/maps-api-loader.service.d.ts +14 -0
  168. package/lib-esm/utils/url-builder.d.ts +20 -0
  169. package/package.json +1 -1
@@ -0,0 +1,707 @@
1
+ import { PolylineEventType } from "../../dto/event-type";
2
+ import { PolylineType } from "../../dto/polyline-type";
3
+ import EventReturn from "../../features/events/event-return";
4
+ var GooglePolylines = /** @class */ (function () {
5
+ function GooglePolylines(map, google, googlePopups) {
6
+ this.map = null;
7
+ this.google = null;
8
+ this.googlePopups = null;
9
+ this.selectedPolyline = null;
10
+ this.selectedPath = null;
11
+ this.navigateInfoWindow = null;
12
+ this.directionForward = false;
13
+ this.multiSelectionForward = false;
14
+ this.multiSelection = false;
15
+ this.navigateByPoint = false;
16
+ this.navigationOptions = {};
17
+ this.map = map;
18
+ this.google = google;
19
+ this.googlePopups = googlePopups;
20
+ }
21
+ GooglePolylines.prototype.drawPolyline = function (options, eventClick) {
22
+ var self = this;
23
+ var newOptions = {
24
+ draggable: options.draggable,
25
+ editable: options.editable,
26
+ icons: null,
27
+ infowindows: options.infowindows,
28
+ object: options.object,
29
+ path: null,
30
+ strokeColor: options.color,
31
+ strokeOpacity: options.opacity || 1,
32
+ strokeWeight: options.weight,
33
+ suppressUndo: true,
34
+ zIndex: options.zIndex,
35
+ };
36
+ if (options.style !== null) {
37
+ switch (options.style) {
38
+ case PolylineType.Dotted:
39
+ console.warn("PolylineType.Dotted is deprecated, instead use PolylineType.Dashed.");
40
+ break;
41
+ case PolylineType.Dashed:
42
+ newOptions.strokeOpacity = 0;
43
+ newOptions.icons = [
44
+ {
45
+ icon: {
46
+ path: "M 0,-1 0,1",
47
+ scale: 2,
48
+ strokeOpacity: 1,
49
+ strokeWeight: options.weight,
50
+ },
51
+ offset: "0",
52
+ repeat: "10px",
53
+ },
54
+ ];
55
+ break;
56
+ case PolylineType.Arrow:
57
+ newOptions.icons = [
58
+ {
59
+ icon: {
60
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
61
+ scaledSize: new google.maps.Size(20, 20),
62
+ size: new google.maps.Size(20, 20),
63
+ },
64
+ offset: "100%",
65
+ repeat: "100px",
66
+ },
67
+ {
68
+ icon: {
69
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
70
+ },
71
+ offset: "0%",
72
+ },
73
+ {
74
+ icon: {
75
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
76
+ },
77
+ offset: "100%",
78
+ },
79
+ ];
80
+ break;
81
+ default:
82
+ break;
83
+ }
84
+ }
85
+ newOptions.path = options.path
86
+ ? options.path.map(function (x) {
87
+ return {
88
+ lat: x[0],
89
+ lng: x[1],
90
+ };
91
+ })
92
+ : [];
93
+ var polyline = new this.google.maps.Polyline(newOptions);
94
+ if (eventClick) {
95
+ this.google.maps.event.addListener(polyline, "click", function (event) {
96
+ var param = new EventReturn([
97
+ event.latLng.lat(),
98
+ event.latLng.lng(),
99
+ ]);
100
+ eventClick(param, polyline.object);
101
+ });
102
+ }
103
+ if (options.addToMap) {
104
+ polyline.setMap(self.map);
105
+ }
106
+ if (options.fitBounds) {
107
+ self.map.fitBounds(self.getPolylineBounds(polyline));
108
+ }
109
+ return polyline;
110
+ };
111
+ GooglePolylines.prototype.drawPolylineWithNavigation = function (options, eventClick) {
112
+ var polyline = this.drawPolyline(options, null);
113
+ polyline.navigationHandlerClick = eventClick;
114
+ this.navigationOptions = options.navigateOptions;
115
+ this.navigateByPoint = this.navigationOptions
116
+ ? this.navigationOptions.navigateByPoint
117
+ : true;
118
+ this.addNavigation(polyline);
119
+ return polyline;
120
+ };
121
+ GooglePolylines.prototype.togglePolylines = function (polylines, show) {
122
+ var _this = this;
123
+ polylines.forEach(function (polyline) {
124
+ var self = _this;
125
+ polyline.setMap(show ? self.map : null);
126
+ });
127
+ };
128
+ GooglePolylines.prototype.alterPolylineOptions = function (polylines, options) {
129
+ polylines.forEach(function (polyline) {
130
+ var newOptions = {
131
+ draggable: options.draggable
132
+ ? options.draggable
133
+ : polyline.draggable,
134
+ editable: options.editable
135
+ ? options.editable
136
+ : polyline.editable,
137
+ infowindows: options.infowindows
138
+ ? options.infowindows
139
+ : polyline.infowindows,
140
+ object: options.object ? options.object : polyline.object,
141
+ strokeColor: options.color
142
+ ? options.color
143
+ : polyline.strokeColor,
144
+ strokeOpacity: options.opacity
145
+ ? options.opacity
146
+ : polyline.strokeOpacity,
147
+ strokeWeight: options.weight
148
+ ? options.weight
149
+ : polyline.strokeWeight,
150
+ zIndex: options.zIndex ? options.zIndex : polyline.zIndex,
151
+ };
152
+ if (options.path) {
153
+ polyline.setPath(options.path.map(function (x) { return new google.maps.LatLng(x[0], x[1]); }));
154
+ }
155
+ switch (options.style) {
156
+ case PolylineType.Dotted:
157
+ console.warn("PolylineType.Dotted is deprecated, instead use PolylineType.Dashed.");
158
+ break;
159
+ case PolylineType.Dashed:
160
+ newOptions.strokeOpacity = 0;
161
+ newOptions.icons = [
162
+ {
163
+ icon: {
164
+ path: "M 0,-1 0,1",
165
+ scale: 2,
166
+ strokeOpacity: 1,
167
+ },
168
+ offset: "0",
169
+ repeat: "10px",
170
+ },
171
+ ];
172
+ break;
173
+ case PolylineType.Arrow:
174
+ newOptions.icons = [
175
+ {
176
+ icon: {
177
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
178
+ scaledSize: new google.maps.Size(20, 20),
179
+ size: new google.maps.Size(20, 20),
180
+ },
181
+ offset: "90%",
182
+ repeat: "20%",
183
+ },
184
+ {
185
+ icon: {
186
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
187
+ },
188
+ offset: "0%",
189
+ },
190
+ {
191
+ icon: {
192
+ path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
193
+ },
194
+ offset: "100%",
195
+ },
196
+ ];
197
+ break;
198
+ default:
199
+ newOptions.icons = null;
200
+ break;
201
+ }
202
+ polyline.setOptions(newOptions);
203
+ });
204
+ };
205
+ GooglePolylines.prototype.fitBoundsPolylines = function (polylines) {
206
+ var self = this;
207
+ self.map.fitBounds(self.getPolylinesBounds(polylines));
208
+ };
209
+ GooglePolylines.prototype.isPolylineOnMap = function (polyline) {
210
+ return !!polyline.map;
211
+ };
212
+ GooglePolylines.prototype.addPolylinePath = function (polylines, position) {
213
+ var _this = this;
214
+ polylines.forEach(function (polyline) {
215
+ var path = polyline.getPath();
216
+ path.push(new _this.google.maps.LatLng(position[0], position[1]));
217
+ polyline.setPath(path);
218
+ });
219
+ };
220
+ GooglePolylines.prototype.getPolylinePath = function (polyline) {
221
+ return polyline
222
+ .getPath()
223
+ .getArray()
224
+ .map(function (x) { return [x.lat(), x.lng()]; });
225
+ };
226
+ GooglePolylines.prototype.removePolylineHighlight = function () {
227
+ this.google.maps.event.clearListeners(document, "keyup");
228
+ this.google.maps.event.clearListeners(document, "keydown");
229
+ if (this.selectedPath) {
230
+ this.selectedPath.setMap(null);
231
+ this.selectedPath = null;
232
+ }
233
+ if (this.navigateInfoWindow) {
234
+ this.navigateInfoWindow.close();
235
+ }
236
+ };
237
+ GooglePolylines.prototype.addPolylineEvent = function (polylines, eventType, eventFunction) {
238
+ var _this = this;
239
+ polylines.forEach(function (polyline) {
240
+ switch (eventType) {
241
+ case PolylineEventType.SetAt:
242
+ _this.addPolylineEventMove(polyline, eventFunction);
243
+ break;
244
+ case PolylineEventType.RightClick:
245
+ _this.addPolylineEventRightClick(polyline, eventFunction);
246
+ break;
247
+ case PolylineEventType.InsertAt:
248
+ _this.addPolylineEventInsertAt(polyline, eventFunction);
249
+ break;
250
+ case PolylineEventType.RemoveAt:
251
+ _this.addPolylineEventRemoveAt(polyline, eventFunction);
252
+ break;
253
+ case PolylineEventType.DragPolyline:
254
+ _this.addPolylineEventDragPolyline(polyline, eventFunction);
255
+ break;
256
+ case PolylineEventType.MouseOver:
257
+ _this.addPolylineEventMouseOver(polyline, eventFunction);
258
+ break;
259
+ case PolylineEventType.MouseOut:
260
+ _this.addPolylineEventMouseOut(polyline, eventFunction);
261
+ break;
262
+ default:
263
+ break;
264
+ }
265
+ });
266
+ };
267
+ GooglePolylines.prototype.removePolylineEvent = function (polylines, event) {
268
+ var _this = this;
269
+ polylines.forEach(function (polyline) {
270
+ return _this.google.maps.event.clearListeners(polyline, "click");
271
+ });
272
+ polylines.forEach(function (polyline) {
273
+ switch (event) {
274
+ case PolylineEventType.SetAt:
275
+ _this.google.maps.event.clearListeners(polyline.getPath(), "set_at");
276
+ break;
277
+ case PolylineEventType.RightClick:
278
+ _this.google.maps.event.clearListeners(polyline, "rightclick");
279
+ break;
280
+ case PolylineEventType.InsertAt:
281
+ _this.google.maps.event.clearListeners(polyline.getPath(), "insert_at");
282
+ break;
283
+ case PolylineEventType.RemoveAt:
284
+ _this.google.maps.event.clearListeners(polyline.getPath(), "remove_at");
285
+ break;
286
+ case PolylineEventType.DragPolyline:
287
+ _this.google.maps.event.clearListeners(polyline, "dragstart");
288
+ _this.google.maps.event.clearListeners(polyline, "dragend");
289
+ break;
290
+ case PolylineEventType.MouseOver:
291
+ _this.google.maps.event.clearListeners(polyline, "mouseover");
292
+ break;
293
+ case PolylineEventType.MouseOut:
294
+ _this.google.maps.event.clearListeners(polyline, "mouseout");
295
+ break;
296
+ default:
297
+ break;
298
+ }
299
+ });
300
+ };
301
+ GooglePolylines.prototype.setIndexPolylineHighlight = function (polyline, index) {
302
+ this.directionForward = false;
303
+ polyline.initialIdx = index;
304
+ polyline.finalIdx = index + 1;
305
+ this.moveSelectedPath(polyline, this.navigationOptions);
306
+ this.selectedPolyline = polyline;
307
+ if (this.navigationOptions.navegateOnKeyPress) {
308
+ this.google.maps.event.clearListeners(document, "keydown");
309
+ this.google.maps.event.addDomListener(document, "keydown", this.onKeyUp.bind(this));
310
+ }
311
+ else {
312
+ this.google.maps.event.clearListeners(document, "keyup");
313
+ this.google.maps.event.addDomListener(document, "keyup", this.onKeyUp.bind(this));
314
+ }
315
+ };
316
+ GooglePolylines.prototype.getObjectPolyline = function (polyline) {
317
+ return polyline.object;
318
+ };
319
+ GooglePolylines.prototype.getObjectPolylineHighlight = function () {
320
+ if (this.selectedPath) {
321
+ return this.selectedPath.object;
322
+ }
323
+ return null;
324
+ };
325
+ GooglePolylines.prototype.addPolylineHighlightEvent = function (eventType, eventFunction) {
326
+ if (this.selectedPath) {
327
+ this.addPolylineEvent([this.selectedPath], eventType, eventFunction);
328
+ }
329
+ };
330
+ GooglePolylines.prototype.getPolylineHighlightIndex = function () {
331
+ if (this.selectedPath) {
332
+ return [this.selectedPath.initialIdx, this.selectedPath.finalIdx];
333
+ }
334
+ return null;
335
+ };
336
+ /* Private methods */
337
+ GooglePolylines.prototype.addNavigation = function (polyline) {
338
+ var self = this;
339
+ this.google.maps.event.clearListeners(polyline, "click");
340
+ this.google.maps.event.addListener(polyline, "click", self.onClickPolyline.bind(self, polyline));
341
+ };
342
+ GooglePolylines.prototype.onClickPolyline = function (polyline, event) {
343
+ var index = this.checkIdx(polyline, event.latLng);
344
+ polyline.initialIdx = index;
345
+ polyline.finalIdx = index + 1;
346
+ this.moveSelectedPath(polyline, this.navigationOptions);
347
+ this.selectedPolyline = polyline;
348
+ if (this.navigationOptions.navegateOnKeyPress) {
349
+ this.google.maps.event.clearListeners(document, "keydown");
350
+ this.google.maps.event.addDomListener(document, "keydown", this.onKeyUp.bind(this));
351
+ }
352
+ else {
353
+ this.google.maps.event.clearListeners(document, "keyup");
354
+ this.google.maps.event.addDomListener(document, "keyup", this.onKeyUp.bind(this));
355
+ }
356
+ if (polyline.navigationHandlerClick) {
357
+ var param = new EventReturn([
358
+ event.latLng.lat(),
359
+ event.latLng.lng(),
360
+ ]);
361
+ polyline.navigationHandlerClick(param, polyline.object);
362
+ }
363
+ };
364
+ GooglePolylines.prototype.onKeyUp = function (event) {
365
+ var self = this;
366
+ if (self.selectedPath) {
367
+ switch (event.which ? event.which : event.keyCode) {
368
+ case 38:
369
+ case 39:
370
+ // up arrow or right arrow
371
+ self.moveForwards(event.shiftKey);
372
+ break;
373
+ case 37:
374
+ case 40:
375
+ // left arrow or down arrow
376
+ self.moveBackwards(event.shiftKey);
377
+ break;
378
+ }
379
+ }
380
+ };
381
+ GooglePolylines.prototype.moveForwards = function (multiSelection) {
382
+ var self = this;
383
+ var polyline = self.selectedPolyline;
384
+ if ((!self.navigateByPoint || self.directionForward) &&
385
+ polyline.finalIdx < polyline.getPath().getArray().length - 1) {
386
+ self.navigateForward(multiSelection, polyline);
387
+ }
388
+ self.directionForward = true;
389
+ self.moveSelectedPath(polyline, null);
390
+ };
391
+ GooglePolylines.prototype.navigateForward = function (multiSelection, polyline) {
392
+ var self = this;
393
+ if (!multiSelection) {
394
+ polyline.finalIdx++;
395
+ polyline.initialIdx = self.multiSelection
396
+ ? polyline.finalIdx - 1
397
+ : polyline.initialIdx + 1;
398
+ self.multiSelection = false;
399
+ }
400
+ else {
401
+ self.multiSelection = true;
402
+ if (self.multiSelectionForward) {
403
+ polyline.finalIdx++;
404
+ }
405
+ self.multiSelectionForward = true;
406
+ }
407
+ };
408
+ GooglePolylines.prototype.moveBackwards = function (multiSelection) {
409
+ var self = this;
410
+ var polyline = self.selectedPolyline;
411
+ if ((!self.navigateByPoint || !self.directionForward) &&
412
+ polyline.initialIdx > 0) {
413
+ self.navigateBackward(multiSelection, polyline);
414
+ }
415
+ self.directionForward = false;
416
+ self.moveSelectedPath(polyline, null);
417
+ };
418
+ GooglePolylines.prototype.navigateBackward = function (multiSelection, polyline) {
419
+ var self = this;
420
+ if (!multiSelection) {
421
+ polyline.initialIdx--;
422
+ polyline.finalIdx = !self.multiSelection
423
+ ? polyline.finalIdx - 1
424
+ : polyline.initialIdx + 1;
425
+ self.multiSelection = false;
426
+ }
427
+ else {
428
+ self.multiSelection = true;
429
+ if (!self.multiSelectionForward) {
430
+ polyline.initialIdx--;
431
+ }
432
+ self.multiSelectionForward = false;
433
+ }
434
+ };
435
+ GooglePolylines.prototype.moveSelectedPath = function (polyline, options) {
436
+ var pathSelected = polyline
437
+ .getPath()
438
+ .getArray()
439
+ .slice(polyline.initialIdx, polyline.finalIdx + 1);
440
+ if (this.selectedPath) {
441
+ this.selectedPath.setPath(pathSelected);
442
+ this.selectedPath.object = polyline.object;
443
+ this.updateSelectedPathListeners();
444
+ }
445
+ else {
446
+ var newOptions = {
447
+ editable: options === null || options === void 0 ? void 0 : options.editable,
448
+ keyboardShortcuts: false,
449
+ map: this.map,
450
+ object: polyline.object,
451
+ path: pathSelected,
452
+ strokeColor: (options && options.color) || "#FF0000",
453
+ strokeOpacity: (options && options.opacity) || 1,
454
+ strokeWeight: (options && options.weight) || 10,
455
+ zIndex: 9999,
456
+ };
457
+ if ((options === null || options === void 0 ? void 0 : options.style) !== null) {
458
+ switch (options === null || options === void 0 ? void 0 : options.style) {
459
+ case PolylineType.Dotted:
460
+ console.warn("PolylineType.Dotted is deprecated, instead use PolylineType.Dashed.");
461
+ break;
462
+ case PolylineType.Dashed:
463
+ newOptions.strokeOpacity = 0;
464
+ newOptions.icons = [
465
+ {
466
+ icon: {
467
+ path: "M 0,-1 0,1",
468
+ scale: 2,
469
+ strokeOpacity: 1,
470
+ },
471
+ offset: "0",
472
+ repeat: "10px",
473
+ },
474
+ ];
475
+ break;
476
+ case PolylineType.Arrow:
477
+ newOptions.icons = [
478
+ {
479
+ icon: {
480
+ anchor: new google.maps.Point(0, 2),
481
+ fillColor: "#000",
482
+ fillOpacity: 0.7,
483
+ path: google.maps.SymbolPath
484
+ .FORWARD_OPEN_ARROW,
485
+ scale: 4,
486
+ strokeColor: "#000",
487
+ strokeWeight: 5,
488
+ },
489
+ offset: "100%",
490
+ },
491
+ ];
492
+ break;
493
+ default:
494
+ break;
495
+ }
496
+ }
497
+ this.selectedPath = new this.google.maps.Polyline(newOptions);
498
+ }
499
+ this.selectedPath.initialIdx = polyline.initialIdx;
500
+ this.selectedPath.finalIdx = polyline.finalIdx;
501
+ this.drawPopupNavigation(polyline);
502
+ };
503
+ GooglePolylines.prototype.addPolylineEventMove = function (polyline, eventFunction) {
504
+ polyline.moveListener = function (newEvent, lastEvent) {
505
+ if (polyline.dragging)
506
+ return;
507
+ var path = polyline.getPath().getAt(newEvent);
508
+ var newPosition = new EventReturn([path.lat(), path.lng()]);
509
+ var lastPosition = new EventReturn([
510
+ lastEvent.lat(),
511
+ lastEvent.lng(),
512
+ ]);
513
+ eventFunction(newPosition, lastPosition, polyline.object, newEvent, polyline
514
+ .getPath()
515
+ .getArray()
516
+ .map(function (x) { return new EventReturn([x.lat(), x.lng()]); }));
517
+ };
518
+ this.google.maps.event.addListener(polyline.getPath(), "set_at", polyline.moveListener);
519
+ };
520
+ GooglePolylines.prototype.addPolylineEventInsertAt = function (polyline, eventFunction) {
521
+ polyline.insertAtListener = function (event) {
522
+ var path = polyline.getPath();
523
+ var newPath = path.getAt(event);
524
+ var newPoint = new EventReturn([newPath.lat(), newPath.lng()]);
525
+ var previousPath = path.getAt(event - 1);
526
+ var previousPoint = previousPath
527
+ ? new EventReturn([previousPath.lat(), previousPath.lng()])
528
+ : null;
529
+ eventFunction(newPoint, previousPoint, polyline.object, event, polyline
530
+ .getPath()
531
+ .getArray()
532
+ .map(function (x) { return new EventReturn([x.lat(), x.lng()]); }));
533
+ };
534
+ this.google.maps.event.addListener(polyline.getPath(), "insert_at", polyline.insertAtListener);
535
+ };
536
+ GooglePolylines.prototype.addPolylineEventRemoveAt = function (polyline, eventFunction) {
537
+ polyline.removeAtListener = function (event) {
538
+ var param = new EventReturn([
539
+ polyline.getPath().getAt(event).lat(),
540
+ polyline.getPath().getAt(event).lng(),
541
+ ]);
542
+ eventFunction(param, polyline.object, polyline
543
+ .getPath()
544
+ .getArray()
545
+ .map(function (x) { return new EventReturn([x.lat(), x.lng()]); }));
546
+ };
547
+ this.google.maps.event.addListener(polyline.getPath(), "remove_at", polyline.removeAtListener);
548
+ };
549
+ GooglePolylines.prototype.addPolylineEventRightClick = function (polyline, eventFunction) {
550
+ polyline.rightClickPolylineListener = function (event) {
551
+ polyline.dragging = false;
552
+ var param = new EventReturn([
553
+ event.latLng.lat(),
554
+ event.latLng.lng(),
555
+ ]);
556
+ eventFunction(param, polyline.object);
557
+ };
558
+ this.google.maps.event.addListener(polyline, "rightclick", polyline.rightClickPolylineListener);
559
+ };
560
+ GooglePolylines.prototype.addPolylineEventMouseOver = function (polyline, eventFunction) {
561
+ polyline.overPolylineListener = function (event) {
562
+ polyline.dragging = false;
563
+ var param = new EventReturn([
564
+ event.latLng.lat(),
565
+ event.latLng.lng(),
566
+ ]);
567
+ eventFunction(param, polyline.object);
568
+ };
569
+ this.google.maps.event.addListener(polyline, "mouseover", polyline.overPolylineListener);
570
+ };
571
+ GooglePolylines.prototype.addPolylineEventMouseOut = function (polyline, eventFunction) {
572
+ polyline.outPolylineListener = function (event) {
573
+ polyline.dragging = false;
574
+ var param = new EventReturn([
575
+ event.latLng.lat(),
576
+ event.latLng.lng(),
577
+ ]);
578
+ eventFunction(param, polyline.object);
579
+ };
580
+ this.google.maps.event.addListener(polyline, "mouseout", polyline.outPolylineListener);
581
+ };
582
+ GooglePolylines.prototype.addPolylineEventDragPolyline = function (polyline, eventFunction) {
583
+ polyline.dragPolylineListener = function () {
584
+ polyline.dragging = false;
585
+ var param = polyline
586
+ .getPath()
587
+ .getArray()
588
+ .map(function (x) { return new EventReturn([x.lat(), x.lng()]); });
589
+ eventFunction(param, polyline.object);
590
+ };
591
+ this.google.maps.event.addListener(polyline, "dragend", polyline.dragPolylineListener);
592
+ this.google.maps.event.addListener(polyline, "dragstart", function () { return (polyline.dragging = true); });
593
+ };
594
+ GooglePolylines.prototype.updateSelectedPathListeners = function () {
595
+ if (this.selectedPath.moveListener) {
596
+ this.google.maps.event.clearListeners(this.selectedPath.getPath(), "set_at");
597
+ this.google.maps.event.addListener(this.selectedPath.getPath(), "set_at", this.selectedPath.moveListener);
598
+ }
599
+ if (this.selectedPath.insertAtListener) {
600
+ this.google.maps.event.clearListeners(this.selectedPath.getPath(), "insert_at");
601
+ this.google.maps.event.addListener(this.selectedPath.getPath(), "insert_at", this.selectedPath.insertAtListener);
602
+ }
603
+ if (this.selectedPath.removeAtListener) {
604
+ this.google.maps.event.clearListeners(this.selectedPath.getPath(), "remove_at");
605
+ this.google.maps.event.addListener(this.selectedPath.getPath(), "remove_at", this.selectedPath.removeAtListener);
606
+ }
607
+ };
608
+ GooglePolylines.prototype.drawPopupNavigation = function (polyline) {
609
+ var _a, _b;
610
+ var self = this;
611
+ var idx = self.directionForward
612
+ ? polyline.finalIdx
613
+ : polyline.initialIdx;
614
+ if (!self.navigateByPoint) {
615
+ idx =
616
+ polyline.finalIdx > polyline.initialIdx
617
+ ? polyline.finalIdx
618
+ : polyline.initialIdx;
619
+ }
620
+ var infowindow = polyline.infowindows
621
+ ? polyline.infowindows[idx]
622
+ : null;
623
+ if (infowindow) {
624
+ var point = polyline.getPath().getArray()[idx];
625
+ if (self.navigateInfoWindow) {
626
+ (_a = this.googlePopups) === null || _a === void 0 ? void 0 : _a.alterPopup(self.navigateInfoWindow, {
627
+ content: infowindow,
628
+ latlng: [point.lat(), point.lng()],
629
+ });
630
+ }
631
+ else {
632
+ self.navigateInfoWindow = (_b = this.googlePopups) === null || _b === void 0 ? void 0 : _b.drawPopup({
633
+ content: infowindow,
634
+ latlng: [point.lat(), point.lng()],
635
+ });
636
+ }
637
+ }
638
+ };
639
+ GooglePolylines.prototype.checkIdx = function (polyline, point) {
640
+ var self = this;
641
+ var path = polyline.getPath();
642
+ var distance = 0;
643
+ var minDistance = Number.MAX_VALUE;
644
+ var returnValue = -1;
645
+ for (var i = 0; i < path.length - 1; i++) {
646
+ distance = self.distanceToLine(path.getAt(i), path.getAt(i + 1), point);
647
+ if (distance < minDistance) {
648
+ minDistance = distance;
649
+ returnValue = i;
650
+ }
651
+ }
652
+ return returnValue;
653
+ };
654
+ GooglePolylines.prototype.distanceToLine = function (pt1, pt2, pt) {
655
+ var self = this;
656
+ var deltaX = pt2.lng() - pt1.lng();
657
+ var deltaY = pt2.lat() - pt1.lat();
658
+ var incIntersect = (pt.lng() - pt1.lng()) * deltaX;
659
+ var deltaSum = deltaX * deltaX + deltaY * deltaY;
660
+ incIntersect += (pt.lat() - pt1.lat()) * deltaY;
661
+ if (deltaSum > 0) {
662
+ incIntersect /= deltaSum;
663
+ }
664
+ else {
665
+ incIntersect = -1;
666
+ }
667
+ // The intersection occurs outside the line segment, 'before' pt1.
668
+ if (incIntersect < 0) {
669
+ return self.kmTo(pt, pt1);
670
+ }
671
+ else if (incIntersect > 1) {
672
+ return self.kmTo(pt, pt2);
673
+ }
674
+ // Intersection point calculation.
675
+ var intersect = new this.google.maps.LatLng(pt1.lat() + incIntersect * deltaY, pt1.lng() + incIntersect * deltaX);
676
+ return self.kmTo(pt, intersect);
677
+ };
678
+ GooglePolylines.prototype.kmTo = function (pt1, pt2) {
679
+ var e = Math;
680
+ var ra = e.PI / 180;
681
+ var b = pt1.lat() * ra;
682
+ var c = pt2.lat() * ra;
683
+ var d = b - c;
684
+ var g = pt1.lng() * ra - pt2.lng() * ra;
685
+ var f = 2 *
686
+ e.asin(e.sqrt(e.pow(e.sin(d / 2), 2) +
687
+ e.cos(b) * e.cos(c) * e.pow(e.sin(g / 2), 2)));
688
+ return f * 6378.137 * 1000;
689
+ };
690
+ GooglePolylines.prototype.getPolylinesBounds = function (polylines) {
691
+ var bounds = new this.google.maps.LatLngBounds();
692
+ polylines.forEach(function (polyline) {
693
+ var paths = polyline.getPath().getArray();
694
+ paths.forEach(function (path) { return bounds.extend(path); });
695
+ });
696
+ return bounds;
697
+ };
698
+ GooglePolylines.prototype.getPolylineBounds = function (polyline) {
699
+ var bounds = new this.google.maps.LatLngBounds();
700
+ var paths = polyline.getPath().getArray();
701
+ paths.forEach(function (path) { return bounds.extend(path); });
702
+ return bounds;
703
+ };
704
+ return GooglePolylines;
705
+ }());
706
+ export default GooglePolylines;
707
+ //# sourceMappingURL=google-polylines.js.map