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