@inlog/inlog-maps 6.0.0 → 6.1.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 (85) hide show
  1. package/lib/index.js +47 -0
  2. package/lib/index.js.map +1 -0
  3. package/lib/map.js +1137 -0
  4. package/lib/map.js.map +1 -0
  5. package/lib/models/apis/google/google-circles.js +134 -0
  6. package/lib/models/apis/google/google-circles.js.map +1 -0
  7. package/lib/models/apis/google/google-geojson.js +73 -0
  8. package/lib/models/apis/google/google-geojson.js.map +1 -0
  9. package/lib/models/apis/google/google-map.js +174 -0
  10. package/lib/models/apis/google/google-map.js.map +1 -0
  11. package/lib/models/apis/google/google-markers.js +325 -0
  12. package/lib/models/apis/google/google-markers.js.map +1 -0
  13. package/lib/models/apis/google/google-overlay.js +102 -0
  14. package/lib/models/apis/google/google-overlay.js.map +1 -0
  15. package/lib/models/apis/google/google-polygons.js +301 -0
  16. package/lib/models/apis/google/google-polygons.js.map +1 -0
  17. package/lib/models/apis/google/google-polylines.js +707 -0
  18. package/lib/models/apis/google/google-polylines.js.map +1 -0
  19. package/lib/models/apis/google/google-popup.js +59 -0
  20. package/lib/models/apis/google/google-popup.js.map +1 -0
  21. package/lib/models/apis/googleMaps.js +449 -0
  22. package/lib/models/apis/googleMaps.js.map +1 -0
  23. package/lib/models/apis/leaflet/leaflet-circle.js +163 -0
  24. package/lib/models/apis/leaflet/leaflet-circle.js.map +1 -0
  25. package/lib/models/apis/leaflet/leaflet-geojson.js +73 -0
  26. package/lib/models/apis/leaflet/leaflet-geojson.js.map +1 -0
  27. package/lib/models/apis/leaflet/leaflet-map.js +140 -0
  28. package/lib/models/apis/leaflet/leaflet-map.js.map +1 -0
  29. package/lib/models/apis/leaflet/leaflet-markers.js +294 -0
  30. package/lib/models/apis/leaflet/leaflet-markers.js.map +1 -0
  31. package/lib/models/apis/leaflet/leaflet-overlay.js +35 -0
  32. package/lib/models/apis/leaflet/leaflet-overlay.js.map +1 -0
  33. package/lib/models/apis/leaflet/leaflet-polygons.js +211 -0
  34. package/lib/models/apis/leaflet/leaflet-polygons.js.map +1 -0
  35. package/lib/models/apis/leaflet/leaflet-polylines.js +706 -0
  36. package/lib/models/apis/leaflet/leaflet-polylines.js.map +1 -0
  37. package/lib/models/apis/leaflet/leaflet-popup.js +74 -0
  38. package/lib/models/apis/leaflet/leaflet-popup.js.map +1 -0
  39. package/lib/models/apis/leaflet.js +464 -0
  40. package/lib/models/apis/leaflet.js.map +1 -0
  41. package/lib/models/apis/mapFunctions.js +2 -0
  42. package/lib/models/apis/mapFunctions.js.map +1 -0
  43. package/lib/models/dto/event-type.js +39 -0
  44. package/lib/models/dto/event-type.js.map +1 -0
  45. package/lib/models/dto/map-type.js +6 -0
  46. package/lib/models/dto/map-type.js.map +1 -0
  47. package/lib/models/dto/polyline-type.js +7 -0
  48. package/lib/models/dto/polyline-type.js.map +1 -0
  49. package/lib/models/features/circle/circle-alter-options.js +14 -0
  50. package/lib/models/features/circle/circle-alter-options.js.map +1 -0
  51. package/lib/models/features/circle/circle-options.js +19 -0
  52. package/lib/models/features/circle/circle-options.js.map +1 -0
  53. package/lib/models/features/events/event-return.js +8 -0
  54. package/lib/models/features/events/event-return.js.map +1 -0
  55. package/lib/models/features/geojson/geojson-options.js +9 -0
  56. package/lib/models/features/geojson/geojson-options.js.map +1 -0
  57. package/lib/models/features/marker/circle-marker-options.js +12 -0
  58. package/lib/models/features/marker/circle-marker-options.js.map +1 -0
  59. package/lib/models/features/marker/circle-marker-style.js +12 -0
  60. package/lib/models/features/marker/circle-marker-style.js.map +1 -0
  61. package/lib/models/features/marker/marker-alter-options.js +10 -0
  62. package/lib/models/features/marker/marker-alter-options.js.map +1 -0
  63. package/lib/models/features/marker/marker-icon.js +10 -0
  64. package/lib/models/features/marker/marker-icon.js.map +1 -0
  65. package/lib/models/features/marker/marker-options.js +18 -0
  66. package/lib/models/features/marker/marker-options.js.map +1 -0
  67. package/lib/models/features/marker-clusterer/marker-clusterer-config.js +10 -0
  68. package/lib/models/features/marker-clusterer/marker-clusterer-config.js.map +1 -0
  69. package/lib/models/features/overlay/overlay-options.js +15 -0
  70. package/lib/models/features/overlay/overlay-options.js.map +1 -0
  71. package/lib/models/features/polygons/polygon-alter-options.js +14 -0
  72. package/lib/models/features/polygons/polygon-alter-options.js.map +1 -0
  73. package/lib/models/features/polygons/polygon-options.js +19 -0
  74. package/lib/models/features/polygons/polygon-options.js.map +1 -0
  75. package/lib/models/features/polyline/navigations-options.js +16 -0
  76. package/lib/models/features/polyline/navigations-options.js.map +1 -0
  77. package/lib/models/features/polyline/polyline-options.js +20 -0
  78. package/lib/models/features/polyline/polyline-options.js.map +1 -0
  79. package/lib/models/features/popup/popup-options.js +13 -0
  80. package/lib/models/features/popup/popup-options.js.map +1 -0
  81. package/lib/utils/maps-api-loader.service.js +89 -0
  82. package/lib/utils/maps-api-loader.service.js.map +1 -0
  83. package/lib/utils/url-builder.js +44 -0
  84. package/lib/utils/url-builder.js.map +1 -0
  85. package/package.json +1 -1
package/lib/map.js ADDED
@@ -0,0 +1,1137 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import GoogleMaps from "./models/apis/googleMaps";
38
+ import Leaflet from "./models/apis/leaflet";
39
+ import { MapType } from "./models/dto/map-type";
40
+ import MarkerClustererConfig from "./models/features/marker-clusterer/marker-clusterer-config";
41
+ import PolylineOptions from "./models/features/polyline/polyline-options";
42
+ var Map = /** @class */ (function () {
43
+ function Map() {
44
+ this.markersList = {};
45
+ this.polygonsList = {};
46
+ this.circlesList = {};
47
+ this.polylinesList = {};
48
+ this.infoWindowList = {};
49
+ this.overlayList = {};
50
+ this.map = {};
51
+ this.markerClusterer = {};
52
+ /**/
53
+ }
54
+ /**
55
+ * Use this to initialize map
56
+ * @param {InlogMaps.MapType} mapType
57
+ * @param {any} options
58
+ * @param {string} elementId default: 'inlog-map' [nullable]
59
+ * @returns {Promisse<any>}
60
+ */
61
+ Map.prototype.initialize = function (mapType, options, elementId) {
62
+ var _a;
63
+ if (elementId === void 0) { elementId = "inlog-map"; }
64
+ this.map =
65
+ mapType === MapType.Google ? new GoogleMaps() : new Leaflet();
66
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.initialize(mapType, options, elementId);
67
+ };
68
+ /* GEOJson */
69
+ /**
70
+ * Use this function to add GEOJSON to the currentMap
71
+ * @param {object} data Geojson
72
+ * @param {InlogMaps.GeoJsonOptions} options
73
+ * @param {any} eventClick is a function callback on click [nullable]
74
+ */
75
+ Map.prototype.loadGEOJson = function (data, options, eventClick) {
76
+ var _a;
77
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.loadGEOJson(data, options, eventClick);
78
+ };
79
+ /* Markers */
80
+ /**
81
+ * Use this function to draw markers in the currentMap
82
+ * @param {string} type
83
+ * @param {InlogMaps.MarkerOptions} options
84
+ * @param {any} eventClick is a function callback on click [nullable]
85
+ */
86
+ Map.prototype.drawMarker = function (type, options, eventClick) {
87
+ var _a, _b;
88
+ var marker = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawMarker(options, eventClick);
89
+ if (!this.markersList[type]) {
90
+ this.markersList[type] = [];
91
+ }
92
+ marker.type = "simple";
93
+ this.markersList[type].push(marker);
94
+ if (options.addClusterer) {
95
+ if (!this.markerClusterer[type]) {
96
+ this.addMarkerClusterer(type, new MarkerClustererConfig(true, 1, 10));
97
+ }
98
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.addMarkerOnClusterer(marker, this.markerClusterer[type]);
99
+ }
100
+ };
101
+ /**
102
+ * Use this function to draw circle markers in the currentMap
103
+ * @param {string} type
104
+ * @param {InlogMaps.CircleMarkerOptions} options
105
+ * @param {any} eventClick is a function callback on click [nullable]
106
+ */
107
+ Map.prototype.drawCircleMarker = function (type, options, eventClick) {
108
+ var _a;
109
+ var marker = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawCircleMarker(options, eventClick);
110
+ if (!this.markersList[type]) {
111
+ this.markersList[type] = [];
112
+ }
113
+ marker.type = "circle";
114
+ this.markersList[type].push(marker);
115
+ };
116
+ /**
117
+ * Use this function to show/hide markers from a specific type
118
+ * @param {boolean} show
119
+ * @param {string} type
120
+ * @param {any} condition toogle markers with the condition [nullable]
121
+ */
122
+ Map.prototype.toggleMarkers = function (show, type, condition) {
123
+ var _a;
124
+ var markers = this.getMarkers(type, condition);
125
+ if (markers && markers.length) {
126
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleMarkers(markers, show, this.markerClusterer[type]);
127
+ }
128
+ };
129
+ /**
130
+ * Remove markers from the map and from internal list
131
+ * @param {string} type
132
+ * @param {any} condition remove markers with the condition [nullable]
133
+ */
134
+ Map.prototype.removeMarkers = function (type, condition) {
135
+ var _a, _b;
136
+ if (this.markersList[type] && condition) {
137
+ var markers = this.getMarkers(type, condition);
138
+ // Hide markers with the condition
139
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleMarkers(markers, false, this.markerClusterer[type]);
140
+ // Keep markers that doesn't have the condition
141
+ this.markersList[type] = this.markersList[type].filter(function (marker) { return !condition(marker.object); });
142
+ }
143
+ else {
144
+ if (this.markersList[type]) {
145
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.toggleMarkers(this.markersList[type], false, this.markerClusterer[type]);
146
+ }
147
+ this.markersList[type] = [];
148
+ }
149
+ if (this.markersList[type].length === 0) {
150
+ delete this.markersList[type];
151
+ }
152
+ };
153
+ /**
154
+ * Remove all markers from the map and from the internal list
155
+ */
156
+ Map.prototype.removeAllMarkers = function () {
157
+ for (var type in this.markersList) {
158
+ if (this.markersList.hasOwnProperty(type)) {
159
+ this.removeMarkers(type);
160
+ }
161
+ }
162
+ };
163
+ /**
164
+ * Use this function to alter marker style
165
+ * @param {string} type
166
+ * @param {InlogMaps.MarkerAlterOptions} options
167
+ * @param {any} condition alter markers with the condition [nullable]
168
+ */
169
+ Map.prototype.alterMarkerOptions = function (type, options, condition) {
170
+ var _a;
171
+ var markers = this.getMarkers(type, condition);
172
+ if (markers && markers.length) {
173
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterMarkerOptions(markers, options);
174
+ }
175
+ };
176
+ /**
177
+ * Use this functions to alterar marker position
178
+ * @param {string } type
179
+ * @param {number[]} position
180
+ * @param {boolean} addTransition [nullable]
181
+ * @param {any} condition [nullable]
182
+ */
183
+ Map.prototype.alterMarkerPosition = function (type, position, addTransition, condition) {
184
+ var _a;
185
+ var markers = this.getMarkers(type, condition);
186
+ if (markers && markers.length) {
187
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterMarkerPosition(markers, position, addTransition !== null && addTransition !== void 0 ? addTransition : false);
188
+ }
189
+ };
190
+ /**
191
+ * Use this function to fit bounds in the markers with the especified type
192
+ * @param {string} type
193
+ * @param {any} condition [nullable]
194
+ * @param {boolean} onlyMarkersOnMap default true
195
+ */
196
+ Map.prototype.fitBoundsMarkers = function (type, condition, onlyMarkersOnMap) {
197
+ var _this = this;
198
+ var _a;
199
+ if (onlyMarkersOnMap === void 0) { onlyMarkersOnMap = true; }
200
+ var markers = this.getMarkers(type, condition);
201
+ if (onlyMarkersOnMap) {
202
+ markers = markers.filter(function (x) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isMarkerOnMap(x); });
203
+ }
204
+ if (markers && markers.length) {
205
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.fitBoundsPositions(markers);
206
+ }
207
+ };
208
+ /**
209
+ * Use this functions to set the center of the map on marker
210
+ * @param {string} type
211
+ * @param {any} condition center on marker with the condition [nullable]
212
+ */
213
+ Map.prototype.setCenterMarker = function (type, condition) {
214
+ var _a, _b;
215
+ if (this.markersList[type] && condition) {
216
+ var marker = this.markersList[type].find(function (marker) {
217
+ return condition(marker.object);
218
+ });
219
+ // Center on the marker with the condition
220
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenterMarker(marker);
221
+ }
222
+ else {
223
+ if (this.markersList[type] && this.markersList[type].length) {
224
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.setCenterMarker(this.markersList[type][0]);
225
+ }
226
+ }
227
+ };
228
+ /**
229
+ * This functions returns if marker exists
230
+ * @param type
231
+ * @param condition [nullable]
232
+ * @returns {boolean}
233
+ */
234
+ Map.prototype.markerExists = function (type, condition) {
235
+ var markers = this.getMarkers(type, condition);
236
+ return markers && markers.length > 0;
237
+ };
238
+ /**
239
+ * Use this function to count markers by type
240
+ * @param {string} type
241
+ * @param {boolean} onlyOnMap exclude hidden markers, default true
242
+ * @param {any} condition
243
+ * @returns {number}
244
+ */
245
+ Map.prototype.countMarkers = function (type, onlyOnMap, condition) {
246
+ var _this = this;
247
+ var _a, _b;
248
+ if (onlyOnMap === void 0) { onlyOnMap = true; }
249
+ if (this.markerClusterer[type]) {
250
+ return ((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.countMarkersOnCluster(this.markerClusterer[type])) !== null && _b !== void 0 ? _b : 0);
251
+ }
252
+ var markers = this.getMarkers(type, condition);
253
+ if (onlyOnMap) {
254
+ markers = markers.filter(function (x) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isMarkerOnMap(x); });
255
+ }
256
+ return markers.length;
257
+ };
258
+ /**
259
+ * This function add new events on marker
260
+ * @param {string} type
261
+ * @param {InlogMaps.MarkerEventType} event
262
+ * @param {any} eventFunction
263
+ * @param {any} condition [nullable]
264
+ */
265
+ Map.prototype.addMarkerEvent = function (type, event, eventFunction, condition) {
266
+ var _a;
267
+ var markers = this.getMarkers(type, condition);
268
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addMarkerEvent(markers, event, eventFunction);
269
+ };
270
+ /**
271
+ * This function remove events of marker
272
+ * @param {string} type
273
+ * @param {InlogMaps.MarkerEventType} event
274
+ * @param {any} condition [nullable]
275
+ */
276
+ Map.prototype.removeMarkerEvent = function (type, event, condition) {
277
+ var _a;
278
+ var markers = this.getMarkers(type, condition);
279
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeMarkerEvent(markers, event);
280
+ };
281
+ /* Marker Clusterer */
282
+ /**
283
+ * Use this function to add MarkerClusterer on the map
284
+ * @param {string} type same type of markers
285
+ * @param {InlogMaps.MarkerClusterConfig} config
286
+ */
287
+ Map.prototype.addMarkerClusterer = function (type, config) {
288
+ var _a;
289
+ this.markerClusterer[type] = (_a = this.map) === null || _a === void 0 ? void 0 : _a.addMarkerClusterer(config);
290
+ };
291
+ /**
292
+ * Use this function to alter clusterer options
293
+ * @param type same type of markers
294
+ * @param {InlogMaps.MarkerClusterConfig} config
295
+ */
296
+ Map.prototype.alterMarkerClustererConfig = function (type, config) {
297
+ var _a;
298
+ if (this.markerClusterer[type]) {
299
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterMarkerClustererConfig(this.markerClusterer[type], config);
300
+ }
301
+ };
302
+ /**
303
+ * Use this function to redraw marker clusterer
304
+ * @param type same type of markers
305
+ */
306
+ Map.prototype.refreshClusterer = function (type) {
307
+ var _a;
308
+ if (this.markerClusterer[type]) {
309
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.refreshClusterer(this.markerClusterer[type]);
310
+ }
311
+ };
312
+ /**
313
+ * Use this to clear markers on clusterer
314
+ * @param type same type of markers
315
+ */
316
+ Map.prototype.clearMarkersClusterer = function (type) {
317
+ var _a;
318
+ if (this.markerClusterer[type]) {
319
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.clearMarkersClusterer(this.markerClusterer[type]);
320
+ }
321
+ };
322
+ /* Polygons */
323
+ /**
324
+ * Use this function to draw polygons
325
+ * @param {string} type
326
+ * @param {InlogMaps.PolygonOptions} options
327
+ * @param {any} eventClick [nullable]
328
+ */
329
+ Map.prototype.drawPolygon = function (type, options, eventClick) {
330
+ var _a;
331
+ var polygon = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawPolygon(options, eventClick);
332
+ if (!this.polygonsList[type]) {
333
+ this.polygonsList[type] = [];
334
+ }
335
+ this.polygonsList[type].push(polygon);
336
+ };
337
+ /**
338
+ * Use this function to show/hide polygon from a especific type
339
+ * @param {boolean} show
340
+ * @param {string} type
341
+ * @param {any} condition toggle polygon with the condition [nullable]
342
+ */
343
+ Map.prototype.togglePolygons = function (show, type, condition) {
344
+ var _a;
345
+ var polygons = this.getPolygons(type, condition);
346
+ if (polygons && polygons.length) {
347
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.togglePolygons(polygons, show);
348
+ }
349
+ };
350
+ /**
351
+ * Remove polygons from the map and from internal list
352
+ * @param {string} type
353
+ * @param {any} condition remove polygons with the condition [nullable]
354
+ */
355
+ Map.prototype.removePolygons = function (type, condition) {
356
+ var _a, _b;
357
+ if (this.polygonsList[type] && condition) {
358
+ var polygons = this.getPolygons(type, condition);
359
+ // Hide markers with the condition
360
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.togglePolygons(polygons, false);
361
+ // Keep markers that doesn't have the condition
362
+ this.polygonsList[type] = this.polygonsList[type].filter(function (polygon) { return !condition(polygon.object); });
363
+ }
364
+ else {
365
+ if (this.polygonsList[type]) {
366
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.togglePolygons(this.polygonsList[type], false);
367
+ }
368
+ this.polygonsList[type] = [];
369
+ }
370
+ if (this.polygonsList[type].length === 0) {
371
+ delete this.polygonsList[type];
372
+ }
373
+ };
374
+ /**
375
+ * Remove all polygons from the map and from the internal list
376
+ */
377
+ Map.prototype.removeAllPolygons = function () {
378
+ for (var type in this.polygonsList) {
379
+ if (this.polygonsList.hasOwnProperty(type)) {
380
+ this.removePolygons(type);
381
+ }
382
+ }
383
+ };
384
+ /**
385
+ * Use this function to alter polygons options/style
386
+ * @param {string} type
387
+ * @param {InlogMaps.PolygonAlterOptions} options
388
+ * @param {any} condition alter polygon with the condition [nullable]
389
+ */
390
+ Map.prototype.alterPolygonOptions = function (type, options, condition) {
391
+ var _a;
392
+ var polygons = this.getPolygons(type, condition);
393
+ if (polygons && polygons.length) {
394
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterPolygonOptions(polygons, options);
395
+ }
396
+ };
397
+ /**
398
+ * Use this function to fit bounds of a polygon
399
+ * @param {string} type
400
+ * @param {any} condition fit polygon bounds with the condition [nullable]
401
+ */
402
+ Map.prototype.fitBoundsPolygons = function (type, condition) {
403
+ var _this = this;
404
+ var _a;
405
+ var polygons = this.getPolygons(type, condition).filter(function (polygon) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isPolygonOnMap(polygon); });
406
+ if (polygons && polygons.length) {
407
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.fitBoundsPolygons(polygons);
408
+ }
409
+ };
410
+ /**
411
+ * Set center on polygon bounds
412
+ * @param {string} type
413
+ * @param {any} condition fit polygon bounds with the condition [nullable]
414
+ */
415
+ Map.prototype.setCenterPolygons = function (type, condition) {
416
+ var _this = this;
417
+ var _a;
418
+ var polygons = this.getPolygons(type, condition).filter(function (polygon) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isPolygonOnMap(polygon); });
419
+ if (polygons && polygons.length) {
420
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenterPolygons(polygons);
421
+ }
422
+ };
423
+ /**
424
+ * This functions returns if polygon exists
425
+ * @param type
426
+ * @param condition [nullable]
427
+ * @returns {boolean}
428
+ */
429
+ Map.prototype.polygonExists = function (type, condition) {
430
+ var polygons = this.getPolygons(type, condition);
431
+ return polygons && polygons.length > 0;
432
+ };
433
+ /**
434
+ * Use this function to get the path of some polygon
435
+ * @param {string} type
436
+ * @param {any} condition
437
+ * @returns {number[]}
438
+ */
439
+ Map.prototype.getPolygonPath = function (type, condition) {
440
+ var _a, _b;
441
+ var polygon = this.getPolygons(type, condition);
442
+ if (polygon && polygon.length) {
443
+ return (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getPolygonPath(polygon[0])) !== null && _b !== void 0 ? _b : [];
444
+ }
445
+ };
446
+ /**
447
+ * This function add new events on polygon
448
+ * @param {string} type
449
+ * @param {InlogMaps.PolygonEventType} event
450
+ * @param {any} eventFunction
451
+ * @param {any} condition [nullable]
452
+ */
453
+ Map.prototype.addPolygonEvent = function (type, event, eventFunction, condition) {
454
+ var _a;
455
+ var polygons = this.getPolygons(type, condition);
456
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolygonEvent(polygons, event, eventFunction);
457
+ };
458
+ /**
459
+ * This function remove events of polygon
460
+ * @param {string} type
461
+ * @param {InlogMaps.PolygonEventType} event
462
+ * @param {any} condition [nullable]
463
+ */
464
+ Map.prototype.removePolygonEvent = function (type, event, condition) {
465
+ var _a;
466
+ var polygons = this.getPolygons(type, condition);
467
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removePolygonEvent(polygons, event);
468
+ };
469
+ /* Circles */
470
+ /**
471
+ * Use this function to draw circles on the currentMap
472
+ * @param {string} type
473
+ * @param {InlogMaps.CircleOptions} options
474
+ * @param {any} eventClick [nullable]
475
+ */
476
+ Map.prototype.drawCircle = function (type, options, eventClick) {
477
+ var _a;
478
+ var circle = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawCircle(options, eventClick);
479
+ if (!this.circlesList[type]) {
480
+ this.circlesList[type] = [];
481
+ }
482
+ this.circlesList[type].push(circle);
483
+ };
484
+ /**
485
+ * Use this function to show/hide circles from a especific type
486
+ * @param {boolean} show
487
+ * @param {string} type
488
+ * @param {any} condition toggle circles with the condition [nullable]
489
+ */
490
+ Map.prototype.toggleCircles = function (show, type, condition) {
491
+ var _a;
492
+ var circles = this.getCircles(type, condition);
493
+ if (circles && circles.length) {
494
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleCircles(circles, show);
495
+ }
496
+ };
497
+ /**
498
+ * Remove circles from the map and from internal list
499
+ * @param {string} type
500
+ * @param {any} condition remove circles with the condition [nullable]
501
+ */
502
+ Map.prototype.removeCircles = function (type, condition) {
503
+ var _a, _b;
504
+ if (this.circlesList[type] && condition) {
505
+ var circles = this.getCircles(type, condition);
506
+ // Hide circles with the condition
507
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleCircles(circles, false);
508
+ // Keep circles that doesn't have the condition
509
+ this.circlesList[type] = this.circlesList[type].filter(function (circle) { return !condition(circle.object); });
510
+ }
511
+ else {
512
+ if (this.circlesList[type]) {
513
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.toggleCircles(this.circlesList[type], false);
514
+ }
515
+ this.circlesList[type] = [];
516
+ }
517
+ if (this.circlesList[type].length === 0) {
518
+ delete this.circlesList[type];
519
+ }
520
+ };
521
+ /**
522
+ * Remove all circles from the map and from the internal list
523
+ */
524
+ Map.prototype.removeAllCircles = function () {
525
+ for (var type in this.circlesList) {
526
+ if (this.circlesList.hasOwnProperty(type)) {
527
+ this.removeCircles(type);
528
+ }
529
+ }
530
+ };
531
+ /**
532
+ * Use this function to alter circle options
533
+ * @param {string} type
534
+ * @param {InlogMaps.CircleAlterOptions} options
535
+ * @param {any} condition alter circle with the condition [nullable]
536
+ */
537
+ Map.prototype.alterCircleOptions = function (type, options, condition) {
538
+ var _a;
539
+ var circles = this.getCircles(type, condition);
540
+ if (circles && circles.length) {
541
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterCircleOptions(circles, options);
542
+ }
543
+ };
544
+ /**
545
+ * Use this function to fit bounds of a polygon
546
+ * @param {string} type
547
+ * @param {any} condition fit polygon bounds with the condition [nullable]
548
+ */
549
+ Map.prototype.fitBoundsCircles = function (type, condition) {
550
+ var _this = this;
551
+ var _a;
552
+ var circles = this.getCircles(type, condition).filter(function (circle) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isCircleOnMap(circle); });
553
+ if (circles && circles.length) {
554
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.fitBoundsCircles(circles);
555
+ }
556
+ };
557
+ /**
558
+ * This functions returns if circle exists
559
+ * @param {string} type
560
+ * @param {any} condition [nullable]
561
+ * @returns {boolean}
562
+ */
563
+ Map.prototype.circleExists = function (type, condition) {
564
+ var circles = this.getCircles(type, condition);
565
+ return circles && circles.length > 0;
566
+ };
567
+ /**
568
+ * This function return circle center
569
+ * @param {string} type
570
+ * @param {any} condition [nullable]
571
+ * @returns {number[]}
572
+ */
573
+ Map.prototype.getCircleCenter = function (type, condition) {
574
+ var _a;
575
+ var circles = this.getCircles(type, condition);
576
+ if (circles && circles.length) {
577
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getCircleCenter(circles[0]);
578
+ }
579
+ return null;
580
+ };
581
+ /**
582
+ * This function return circle center
583
+ * @param {string} type
584
+ * @param {any} condition [nullable]
585
+ * @returns {number}
586
+ */
587
+ Map.prototype.getCircleRadius = function (type, condition) {
588
+ var _a;
589
+ var circles = this.getCircles(type, condition);
590
+ if (circles && circles.length) {
591
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getCircleRadius(circles[0]);
592
+ }
593
+ return null;
594
+ };
595
+ /**
596
+ * This function add new events on circle
597
+ * @param {string} type
598
+ * @param {InlogMaps.CircleEventType} event
599
+ * @param {any} eventFunction
600
+ * @param {any} condition [nullable]
601
+ */
602
+ Map.prototype.addCircleEvent = function (type, event, eventFunction, condition) {
603
+ var _a;
604
+ var circles = this.getCircles(type, condition);
605
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addCircleEvent(circles, event, eventFunction);
606
+ };
607
+ /**
608
+ * This function remove events of circle
609
+ * @param {string} type
610
+ * @param {InlogMaps.CircleEventType} event
611
+ * @param {any} condition [nullable]
612
+ */
613
+ Map.prototype.removeCircleEvent = function (type, event, condition) {
614
+ var _a;
615
+ var circles = this.getCircles(type, condition);
616
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeCircleEvent(circles, event);
617
+ };
618
+ /* Polylines */
619
+ /**
620
+ * Use this function to draw polylines on the currentMap
621
+ * @param {string} type
622
+ * @param {InlogMaps.PolylineOptions} options
623
+ * @param {any} eventClick [nullable]
624
+ */
625
+ Map.prototype.drawPolyline = function (type, options, eventClick) {
626
+ var _a;
627
+ var polyline = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawPolyline(options, eventClick);
628
+ if (!this.polylinesList[type]) {
629
+ this.polylinesList[type] = [];
630
+ }
631
+ this.polylinesList[type].push(polyline);
632
+ };
633
+ /**
634
+ * Use this function to draw polylines with navigation on the currentMap
635
+ * @param {string} type
636
+ * @param {InlogMaps.PolylineOptions} options
637
+ */
638
+ Map.prototype.drawPolylineWithNavigation = function (type, options, eventClick) {
639
+ var _a;
640
+ var polyline = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawPolylineWithNavigation(options, eventClick);
641
+ if (!this.polylinesList[type]) {
642
+ this.polylinesList[type] = [];
643
+ }
644
+ this.polylinesList[type].push(polyline);
645
+ };
646
+ /**
647
+ * Use this function to toggle polylines
648
+ * @param {boolean} show
649
+ * @param {string} type
650
+ * @param {any} condition toggle polyline with the condition [nullable]
651
+ */
652
+ Map.prototype.togglePolylines = function (show, type, condition) {
653
+ var _a;
654
+ var polyline = this.getPolylines(type, condition);
655
+ if (polyline && polyline.length) {
656
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.togglePolylines(polyline, show);
657
+ }
658
+ };
659
+ /**
660
+ * Use this function to remove polylines
661
+ * @param {string} type
662
+ * @param {any} condition remove polyline with the condition [nullable]
663
+ */
664
+ Map.prototype.removePolylines = function (type, condition) {
665
+ var _a, _b;
666
+ if (this.polylinesList[type] && condition) {
667
+ var polylines = this.getPolylines(type, condition);
668
+ // Hide markers with the condition
669
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.togglePolylines(polylines, false);
670
+ // Keep markers that doesn't have the condition
671
+ this.polylinesList[type] = this.polylinesList[type].filter(function (polyline) { return !condition(polyline.object); });
672
+ }
673
+ else {
674
+ if (this.polylinesList[type]) {
675
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.togglePolylines(this.polylinesList[type], false);
676
+ }
677
+ this.polylinesList[type] = [];
678
+ }
679
+ if (this.polylinesList[type].length === 0) {
680
+ delete this.polylinesList[type];
681
+ }
682
+ };
683
+ /**
684
+ * Remove all polylines from the map and from the internal list
685
+ */
686
+ Map.prototype.removeAllPolylines = function () {
687
+ for (var type in this.polylinesList) {
688
+ if (this.polylinesList.hasOwnProperty(type)) {
689
+ this.removePolylines(type);
690
+ }
691
+ }
692
+ };
693
+ /**
694
+ * Use this function to alter polyline options
695
+ * @param {string} type
696
+ * @param {InlogMaps.PolylineOptions} options
697
+ * @param {any} condition alter polyline with the condition [nullable]
698
+ */
699
+ Map.prototype.alterPolylineOptions = function (type, options, condition) {
700
+ var _a;
701
+ var polyline = this.getPolylines(type, condition);
702
+ if (polyline && polyline.length) {
703
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterPolylineOptions(polyline, options);
704
+ }
705
+ };
706
+ /**
707
+ * Use this functions to fit polylines bounds
708
+ * @param {string} type
709
+ * @param {any} condition [nullable]
710
+ */
711
+ Map.prototype.fitBoundsPolylines = function (type, condition) {
712
+ var _this = this;
713
+ var _a;
714
+ var polylines = this.getPolylines(type, condition).filter(function (polyline) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isPolylineOnMap(polyline); });
715
+ if (polylines && polylines.length) {
716
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.fitBoundsPolylines(polylines);
717
+ }
718
+ };
719
+ /**
720
+ * This functions returns if polyline exists
721
+ * @param {string} type
722
+ * @param {any} condition [nullable]
723
+ * @returns {boolean}
724
+ */
725
+ Map.prototype.polylineExists = function (type, condition) {
726
+ var polylines = this.getPolylines(type, condition);
727
+ return polylines && polylines.length > 0;
728
+ };
729
+ /**
730
+ * Use this function to add more paths to a polyline
731
+ * @param {string} type
732
+ * @param {number[]} position
733
+ * @param {any} condition [nullable]
734
+ */
735
+ Map.prototype.addPolylinePath = function (type, position, condition) {
736
+ var _a;
737
+ var polyline = this.getPolylines(type, condition);
738
+ if (polyline && polyline.length) {
739
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylinePath(polyline, position);
740
+ }
741
+ else {
742
+ var options = new PolylineOptions();
743
+ options.addToMap = true;
744
+ this.drawPolyline(type, options, null);
745
+ }
746
+ };
747
+ /**
748
+ * Use this function to get the path of some polyline
749
+ * @param {string} type
750
+ * @param {any} condition
751
+ * @returns {number[]}
752
+ */
753
+ Map.prototype.getPolylinePath = function (type, condition) {
754
+ var polyline = this.getPolylines(type, condition);
755
+ if (polyline && polyline.length) {
756
+ return this.map.getPolylinePath(polyline[0]);
757
+ }
758
+ };
759
+ /**
760
+ * Use this function to clear polyline selected from the currentMap
761
+ */
762
+ Map.prototype.removePolylineHighlight = function () {
763
+ var _a;
764
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removePolylineHighlight();
765
+ };
766
+ /**
767
+ * Use this function to add listeners on polyline
768
+ * @param {string} type
769
+ * @param {InlogMaps.PolylineEventType} event
770
+ * @param {any} eventFunction
771
+ * @param {any} condition [nullable]
772
+ */
773
+ Map.prototype.addPolylineEvent = function (type, event, eventFunction, condition) {
774
+ var _a;
775
+ var polyline = this.getPolylines(type, condition);
776
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineEvent(polyline, event, eventFunction);
777
+ };
778
+ /**
779
+ * Use this function to remove listeners of polyline
780
+ * @param {string} type
781
+ * @param {InlogMaps.PolylineEventType} event
782
+ * @param {any} condition [nullable]
783
+ */
784
+ Map.prototype.removePolylineEvent = function (type, event, condition) {
785
+ var _a;
786
+ var polyline = this.getPolylines(type, condition);
787
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removePolylineEvent(polyline, event);
788
+ };
789
+ /**
790
+ * Use this function to set position of polyline highlight
791
+ * @param {string} type
792
+ * @param {number} initialIndex
793
+ * @param {any} condition [nullable]
794
+ */
795
+ Map.prototype.setIndexPolylineHighlight = function (type, initialIndex, condition) {
796
+ var _a;
797
+ var polylines = this.getPolylines(type, condition);
798
+ if (polylines && polylines.length) {
799
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setIndexPolylineHighlight(polylines[0], initialIndex);
800
+ }
801
+ };
802
+ /**
803
+ * Use this function to get the object of a polyline
804
+ * @param {string} type
805
+ * @param {any} condition
806
+ * @returns {object}
807
+ */
808
+ Map.prototype.getObjectPolyline = function (type, condition) {
809
+ var _a;
810
+ var polylines = this.getPolylines(type, condition);
811
+ if (polylines && polylines.length) {
812
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getObjectPolyline(polylines[0]);
813
+ }
814
+ else {
815
+ return null;
816
+ }
817
+ };
818
+ /**
819
+ * Use this function to get the object of the polyline highligth
820
+ * @returns {object}
821
+ */
822
+ Map.prototype.getObjectPolylineHighlight = function () {
823
+ var _a;
824
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getObjectPolylineHighlight();
825
+ };
826
+ /**
827
+ * Use this function to add events on polyline highligtht / selected polyline
828
+ * @param {InlogMaps.PolylineEventType} event
829
+ * @param {any} eventFunction
830
+ */
831
+ Map.prototype.addPolylineHighlightEvent = function (event, eventFunction) {
832
+ var _a;
833
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addPolylineHighlightEvent(event, eventFunction);
834
+ };
835
+ /**
836
+ * Use this function to get initial and final index of the polyline highlight
837
+ * @returns {number[]} returns an array with initial index and final index
838
+ */
839
+ Map.prototype.getPolylineHighlightIndex = function () {
840
+ var _a;
841
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getPolylineHighlightIndex();
842
+ };
843
+ /* Info Windows */
844
+ /**
845
+ * Use this function to draw popups on the currentMap
846
+ * @param {string} type
847
+ * @param {InlogMaps.PopupOptions} options
848
+ */
849
+ Map.prototype.drawPopup = function (type, options) {
850
+ var _a, _b;
851
+ var marker = null;
852
+ if (options.marker) {
853
+ var markers = this.getMarkers(options.marker, options.conditionMarker);
854
+ marker = markers[0];
855
+ }
856
+ var popup;
857
+ if (this.infoWindowList[type]) {
858
+ popup = (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterPopup(this.infoWindowList[type], options, marker);
859
+ }
860
+ else {
861
+ popup = (_b = this.map) === null || _b === void 0 ? void 0 : _b.drawPopup(options, marker);
862
+ }
863
+ this.infoWindowList[type] = popup;
864
+ };
865
+ /**
866
+ * Use this function to alter popups
867
+ * @param {string} type
868
+ * @param {InlogMaps.PopupOptions} options
869
+ */
870
+ Map.prototype.alterPopup = function (type, options) {
871
+ var _a;
872
+ var popups = this.infoWindowList[type];
873
+ var markers;
874
+ if (options.marker) {
875
+ markers = this.getMarkers(options.marker, options.conditionMarker);
876
+ }
877
+ if (popups) {
878
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.alterPopupContent(popups, options, markers ? markers[0] : null);
879
+ }
880
+ };
881
+ /**
882
+ *
883
+ * @param {string} type
884
+ * @returns {object}
885
+ */
886
+ Map.prototype.getObjectOpenPopup = function (type) {
887
+ return this.infoWindowList[type]
888
+ ? this.infoWindowList[type].object
889
+ : null;
890
+ };
891
+ /**
892
+ * Use this function to close popup by type
893
+ * @param {string} type
894
+ */
895
+ Map.prototype.closePopup = function (type) {
896
+ var _a;
897
+ if (this.infoWindowList[type]) {
898
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.closePopup(this.infoWindowList[type]);
899
+ }
900
+ };
901
+ /**
902
+ * Use this function to close all popups
903
+ * @param {string} type
904
+ */
905
+ Map.prototype.closeAllPopups = function () {
906
+ for (var type in this.infoWindowList) {
907
+ if (this.infoWindowList.hasOwnProperty(type)) {
908
+ this.closePopup(type);
909
+ }
910
+ }
911
+ };
912
+ /* Map */
913
+ /**
914
+ * Resize de map based on html size
915
+ */
916
+ Map.prototype.resizeMap = function () {
917
+ var _a;
918
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.resizeMap();
919
+ };
920
+ /**
921
+ * Use this function to add event clicks on the currentMap
922
+ * @param {InlogMaps.MapEventType} eventType
923
+ * @param eventFunction function callback
924
+ */
925
+ Map.prototype.addEventMap = function (eventType, eventFunction) {
926
+ var _a;
927
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.addEventMap(eventType, eventFunction);
928
+ };
929
+ /**
930
+ * Use this function to remove event clicks from the currentMap
931
+ * @param {InlogMaps.MapEventType} eventType
932
+ */
933
+ Map.prototype.removeEventMap = function (eventType) {
934
+ var _a;
935
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeEventMap(eventType);
936
+ };
937
+ /**
938
+ * Returns the current zoom level of the map view
939
+ * @returns {number}
940
+ */
941
+ Map.prototype.getZoom = function () {
942
+ var _a;
943
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
944
+ };
945
+ /**
946
+ * Set the current zoom level of the map view
947
+ * @param {number} zoom
948
+ */
949
+ Map.prototype.setZoom = function (zoom) {
950
+ var _a;
951
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setZoom(zoom);
952
+ };
953
+ /**
954
+ * Takes a screenshot with all the context included in it (visible area)
955
+ * Returns the image as a base64 string or null
956
+ * @returns {Promise<string | null>}
957
+ */
958
+ Map.prototype.takeMapScreenshot = function () {
959
+ var _a;
960
+ return __awaiter(this, void 0, void 0, function () {
961
+ return __generator(this, function (_b) {
962
+ switch (_b.label) {
963
+ case 0: return [4 /*yield*/, ((_a = this.map) === null || _a === void 0 ? void 0 : _a.takeMapScreenshot())];
964
+ case 1: return [2 /*return*/, _b.sent()];
965
+ }
966
+ });
967
+ });
968
+ };
969
+ /**
970
+ * Returns the center position of the map
971
+ * @returns {number[]}
972
+ */
973
+ Map.prototype.getCenter = function () {
974
+ var _a;
975
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.getCenter();
976
+ };
977
+ /**
978
+ * Set the position center of the map
979
+ * @param {number[]} position
980
+ */
981
+ Map.prototype.setCenter = function (position) {
982
+ var _a;
983
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.setCenter(position);
984
+ };
985
+ /**
986
+ * Returns the coordinates from pixels
987
+ * @param {number} offsetx
988
+ * @param {number} offsety
989
+ * @returns {number[]}
990
+ */
991
+ Map.prototype.pixelsToLatLng = function (offsetx, offsety) {
992
+ var _a;
993
+ return (_a = this.map) === null || _a === void 0 ? void 0 : _a.pixelsToLatLng(offsetx, offsety);
994
+ };
995
+ /**
996
+ * Use this functions to fit bounds on elements with same type and condition
997
+ * @param {string} type
998
+ * @param {any} condition [nullable]
999
+ */
1000
+ Map.prototype.fitBoundsElements = function (type, condition) {
1001
+ var _this = this;
1002
+ var _a;
1003
+ var markers = this.getMarkers(type, condition).filter(function (marker) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isMarkerOnMap(marker); });
1004
+ var circles = this.getCircles(type, condition).filter(function (circle) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isCircleOnMap(circle); });
1005
+ var polygons = this.getPolygons(type, condition).filter(function (polygon) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isPolygonOnMap(polygon); });
1006
+ var polylines = this.getPolylines(type, condition).filter(function (polyline) { var _a; return (_a = _this.map) === null || _a === void 0 ? void 0 : _a.isPolylineOnMap(polyline); });
1007
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.fitBoundsElements(markers, circles, polygons, polylines);
1008
+ };
1009
+ /* Overlay */
1010
+ /**
1011
+ * Use this function to dray overlays on the current map
1012
+ * @param {string} type
1013
+ * @param {InlogMaps.OverlayOptions} options
1014
+ */
1015
+ Map.prototype.drawOverlay = function (type, options) {
1016
+ var _a, _b;
1017
+ var overlay = null;
1018
+ if (options.polygon) {
1019
+ var polygons = this.getPolygons(options.polygon, options.conditionPolygon);
1020
+ if (polygons && polygons.length) {
1021
+ overlay = (_a = this.map) === null || _a === void 0 ? void 0 : _a.drawOverlay(options, polygons);
1022
+ }
1023
+ }
1024
+ else {
1025
+ overlay = (_b = this.map) === null || _b === void 0 ? void 0 : _b.drawOverlay(options);
1026
+ }
1027
+ if (overlay != null) {
1028
+ if (!this.overlayList[type]) {
1029
+ this.overlayList[type] = [];
1030
+ }
1031
+ this.overlayList[type].push(overlay);
1032
+ }
1033
+ };
1034
+ /**
1035
+ * Use this function to show or hide overlay
1036
+ * @param {boolean} show
1037
+ * @param {string} type
1038
+ * @param {any} condition [nullable]
1039
+ */
1040
+ Map.prototype.toggleOverlay = function (show, type, condition) {
1041
+ var _a;
1042
+ var overlays = this.getOverlays(type, condition);
1043
+ if (overlays && overlays.length) {
1044
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleOverlay(overlays, show);
1045
+ }
1046
+ };
1047
+ /**
1048
+ * Remove overlays from the map and from internal list
1049
+ * @param {string} type
1050
+ * @param {any} condition remove overlays with the condition [nullable]
1051
+ */
1052
+ Map.prototype.removeOverlays = function (type, condition) {
1053
+ var _a, _b;
1054
+ if (this.overlayList[type] && condition) {
1055
+ var overlays = this.getOverlays(type, condition);
1056
+ // Hide markers with the condition
1057
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.toggleOverlay(overlays, false);
1058
+ // Keep markers that doesn't have the condition
1059
+ this.overlayList[type] = this.overlayList[type].filter(function (overlay) { return !condition(overlay.object); });
1060
+ }
1061
+ else {
1062
+ if (this.overlayList[type]) {
1063
+ (_b = this.map) === null || _b === void 0 ? void 0 : _b.toggleOverlay(this.overlayList[type], false);
1064
+ }
1065
+ this.overlayList[type] = [];
1066
+ }
1067
+ if (this.overlayList[type].length === 0) {
1068
+ delete this.overlayList[type];
1069
+ }
1070
+ };
1071
+ /**
1072
+ * Remove all overlays from the map and from the internal list
1073
+ */
1074
+ Map.prototype.removeAllOverlays = function () {
1075
+ for (var type in this.overlayList) {
1076
+ if (this.overlayList.hasOwnProperty(type)) {
1077
+ this.removeOverlays(type);
1078
+ }
1079
+ }
1080
+ };
1081
+ /* Private Methods */
1082
+ Map.prototype.getMarkers = function (type, condition) {
1083
+ var markers = this.markersList[type];
1084
+ if (markers && markers.length) {
1085
+ return condition
1086
+ ? markers.filter(function (marker) { return condition(marker.object); })
1087
+ : markers;
1088
+ }
1089
+ else
1090
+ return [];
1091
+ };
1092
+ Map.prototype.getPolygons = function (type, condition) {
1093
+ var polygons = this.polygonsList[type];
1094
+ if (polygons && polygons.length) {
1095
+ return condition
1096
+ ? polygons.filter(function (polygon) { return condition(polygon.object); })
1097
+ : polygons;
1098
+ }
1099
+ else
1100
+ return [];
1101
+ };
1102
+ Map.prototype.getCircles = function (type, condition) {
1103
+ var circles = this.circlesList[type];
1104
+ if (circles && circles.length) {
1105
+ return condition
1106
+ ? circles.filter(function (circle) { return condition(circle.object); })
1107
+ : circles;
1108
+ }
1109
+ else
1110
+ return [];
1111
+ };
1112
+ Map.prototype.getPolylines = function (type, condition) {
1113
+ var polylines = this.polylinesList[type];
1114
+ if (polylines && polylines.length) {
1115
+ return condition
1116
+ ? polylines.filter(function (polyline) {
1117
+ return condition(polyline.object);
1118
+ })
1119
+ : polylines;
1120
+ }
1121
+ else
1122
+ return [];
1123
+ };
1124
+ Map.prototype.getOverlays = function (type, condition) {
1125
+ var overlays = this.overlayList[type];
1126
+ if (overlays && overlays.length) {
1127
+ return condition
1128
+ ? overlays.filter(function (overlay) { return condition(overlay.object); })
1129
+ : overlays;
1130
+ }
1131
+ else
1132
+ return [];
1133
+ };
1134
+ return Map;
1135
+ }());
1136
+ export default Map;
1137
+ //# sourceMappingURL=map.js.map