mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34

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 (225) hide show
  1. package/api/RealtimeAPI.d.ts +268 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +626 -343
  4. package/api/RoutingAPI.d.ts +33 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +65 -15
  7. package/api/StopsAPI.d.ts +36 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +70 -12
  10. package/api/index.d.ts +5 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +10 -3
  13. package/api/typedefs.d.ts +105 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/api/typedefs.js +72 -0
  16. package/common/api/HttpAPI.d.ts +31 -0
  17. package/common/api/HttpAPI.d.ts.map +1 -0
  18. package/common/api/HttpAPI.js +82 -30
  19. package/common/api/WebSocketAPI.d.ts +95 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +313 -168
  22. package/common/controls/Control.d.ts +74 -0
  23. package/common/controls/Control.d.ts.map +1 -0
  24. package/common/controls/Control.js +167 -78
  25. package/common/index.d.ts +3 -0
  26. package/common/index.d.ts.map +1 -0
  27. package/common/index.js +18 -2
  28. package/common/layers/Layer.d.ts +80 -0
  29. package/common/layers/Layer.d.ts.map +1 -0
  30. package/common/layers/Layer.js +251 -134
  31. package/common/mixins/CopyrightMixin.d.ts +22 -0
  32. package/common/mixins/CopyrightMixin.d.ts.map +1 -0
  33. package/common/mixins/CopyrightMixin.js +70 -22
  34. package/common/mixins/MapboxLayerMixin.d.ts +27 -0
  35. package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
  36. package/common/mixins/MapboxLayerMixin.js +240 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +698 -429
  40. package/common/mixins/StopFinderMixin.d.ts +40 -0
  41. package/common/mixins/StopFinderMixin.d.ts.map +1 -0
  42. package/common/mixins/StopFinderMixin.js +195 -107
  43. package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
  44. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  45. package/common/mixins/UserInteractionsLayerMixin.js +222 -121
  46. package/common/styles/index.d.ts +5 -0
  47. package/common/styles/index.d.ts.map +1 -0
  48. package/common/styles/index.js +24 -4
  49. package/common/styles/realtimeDefaultStyle.d.ts +15 -0
  50. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDefaultStyle.js +236 -190
  52. package/common/styles/realtimeDelayStyle.d.ts +11 -0
  53. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeDelayStyle.js +25 -7
  55. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -17
  58. package/common/typedefs.d.ts +50 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +21 -0
  61. package/common/utils/cleanStopTime.d.ts +7 -0
  62. package/common/utils/cleanStopTime.d.ts.map +1 -0
  63. package/common/utils/cleanStopTime.js +28 -17
  64. package/common/utils/compareDepartures.d.ts +9 -0
  65. package/common/utils/compareDepartures.d.ts.map +1 -0
  66. package/common/utils/compareDepartures.js +34 -22
  67. package/common/utils/createCanvas.d.ts +9 -0
  68. package/common/utils/createCanvas.d.ts.map +1 -0
  69. package/common/utils/createCanvas.js +28 -16
  70. package/common/utils/createTrackerFilters.d.ts +12 -0
  71. package/common/utils/createTrackerFilters.d.ts.map +1 -0
  72. package/common/utils/createTrackerFilters.js +75 -54
  73. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  74. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  75. package/common/utils/getLayersAsFlatArray.js +15 -13
  76. package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
  77. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  78. package/common/utils/getMapboxMapCopyrights.js +24 -17
  79. package/common/utils/getMapboxRender.d.ts +5 -0
  80. package/common/utils/getMapboxRender.d.ts.map +1 -0
  81. package/common/utils/getMapboxRender.js +77 -0
  82. package/common/utils/getMaplibreRender.d.ts +5 -0
  83. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  84. package/common/utils/getMaplibreRender.js +38 -0
  85. package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
  86. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  87. package/common/utils/getRealtimeModeSuffix.js +11 -2
  88. package/common/utils/getUrlWithParams.d.ts +9 -0
  89. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  90. package/common/utils/getUrlWithParams.js +20 -10
  91. package/common/utils/getVehiclePosition.d.ts +14 -0
  92. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  93. package/common/utils/getVehiclePosition.js +63 -39
  94. package/common/utils/index.d.ts +12 -0
  95. package/common/utils/index.d.ts.map +1 -0
  96. package/common/utils/index.js +37 -9
  97. package/common/utils/removeDuplicate.d.ts +10 -0
  98. package/common/utils/removeDuplicate.d.ts.map +1 -0
  99. package/common/utils/removeDuplicate.js +29 -7
  100. package/common/utils/renderTrajectories.d.ts +20 -0
  101. package/common/utils/renderTrajectories.d.ts.map +1 -0
  102. package/common/utils/renderTrajectories.js +111 -78
  103. package/common/utils/sortByDelay.d.ts +3 -0
  104. package/common/utils/sortByDelay.d.ts.map +1 -0
  105. package/common/utils/sortByDelay.js +21 -17
  106. package/common/utils/timeUtils.d.ts +5 -0
  107. package/common/utils/timeUtils.d.ts.map +1 -0
  108. package/common/utils/timeUtils.js +47 -18
  109. package/common/utils/trackerConfig.d.ts +24 -0
  110. package/common/utils/trackerConfig.d.ts.map +1 -0
  111. package/common/utils/trackerConfig.js +171 -118
  112. package/iife.d.ts +3 -0
  113. package/iife.d.ts.map +1 -0
  114. package/iife.js +7 -0
  115. package/index.d.ts +6 -0
  116. package/index.d.ts.map +1 -0
  117. package/index.js +10 -7
  118. package/mapbox/controls/CopyrightControl.d.ts +32 -0
  119. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  120. package/mapbox/controls/CopyrightControl.js +72 -28
  121. package/mapbox/controls/index.d.ts +2 -0
  122. package/mapbox/controls/index.d.ts.map +1 -0
  123. package/mapbox/controls/index.js +6 -1
  124. package/mapbox/index.d.ts +5 -0
  125. package/mapbox/index.d.ts.map +1 -0
  126. package/mapbox/index.js +20 -4
  127. package/mapbox/layers/Layer.d.ts +47 -0
  128. package/mapbox/layers/Layer.d.ts.map +1 -0
  129. package/mapbox/layers/Layer.js +137 -54
  130. package/mapbox/layers/RealtimeLayer.d.ts +118 -0
  131. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  132. package/mapbox/layers/RealtimeLayer.js +310 -183
  133. package/mapbox/layers/index.d.ts +3 -0
  134. package/mapbox/layers/index.d.ts.map +1 -0
  135. package/mapbox/layers/index.js +7 -2
  136. package/mapbox/utils.d.ts +8 -0
  137. package/mapbox/utils.d.ts.map +1 -0
  138. package/mapbox/utils.js +54 -29
  139. package/mbt.js +2052 -2109
  140. package/mbt.js.map +3 -3
  141. package/mbt.min.js +18 -18
  142. package/mbt.min.js.map +3 -3
  143. package/ol/controls/CopyrightControl.d.ts +31 -0
  144. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  145. package/ol/controls/CopyrightControl.js +89 -41
  146. package/ol/controls/RoutingControl.d.ts +180 -0
  147. package/ol/controls/RoutingControl.d.ts.map +1 -0
  148. package/ol/controls/RoutingControl.js +666 -371
  149. package/ol/controls/StopFinderControl.d.ts +32 -0
  150. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  151. package/ol/controls/StopFinderControl.js +59 -10
  152. package/ol/controls/index.d.ts +4 -0
  153. package/ol/controls/index.d.ts.map +1 -0
  154. package/ol/controls/index.js +9 -3
  155. package/ol/index.d.ts +6 -0
  156. package/ol/index.d.ts.map +1 -0
  157. package/ol/index.js +21 -5
  158. package/ol/layers/Layer.d.ts +49 -0
  159. package/ol/layers/Layer.d.ts.map +1 -0
  160. package/ol/layers/Layer.js +178 -81
  161. package/ol/layers/MapboxLayer.d.ts +42 -0
  162. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  163. package/ol/layers/MapboxLayer.js +131 -198
  164. package/ol/layers/MapboxStyleLayer.d.ts +146 -0
  165. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  166. package/ol/layers/MapboxStyleLayer.js +382 -186
  167. package/ol/layers/MaplibreLayer.d.ts +27 -0
  168. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  169. package/ol/layers/MaplibreLayer.js +67 -138
  170. package/ol/layers/RealtimeLayer.d.ts +119 -0
  171. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  172. package/ol/layers/RealtimeLayer.js +327 -184
  173. package/ol/layers/RoutingLayer.d.ts +24 -0
  174. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  175. package/ol/layers/RoutingLayer.js +111 -56
  176. package/ol/layers/VectorLayer.d.ts +23 -0
  177. package/ol/layers/VectorLayer.d.ts.map +1 -0
  178. package/ol/layers/VectorLayer.js +71 -21
  179. package/ol/layers/WMSLayer.d.ts +38 -0
  180. package/ol/layers/WMSLayer.d.ts.map +1 -0
  181. package/ol/layers/WMSLayer.js +105 -37
  182. package/ol/layers/index.d.ts +9 -0
  183. package/ol/layers/index.d.ts.map +1 -0
  184. package/ol/layers/index.js +19 -8
  185. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  186. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  187. package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
  188. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  189. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  190. package/ol/styles/fullTrajectoryStyle.js +44 -40
  191. package/ol/styles/index.d.ts +3 -0
  192. package/ol/styles/index.d.ts.map +1 -0
  193. package/ol/styles/index.js +7 -2
  194. package/package.json +14 -36
  195. package/setupTests.d.ts +2 -0
  196. package/setupTests.d.ts.map +1 -0
  197. package/setupTests.js +15 -0
  198. package/types/index.d.ts +7 -6
  199. package/types/routing.d.ts +25 -25
  200. package/types/stops.d.ts +19 -19
  201. package/api/RealtimeAPI.test.js +0 -67
  202. package/api/RoutingAPI.test.js +0 -25
  203. package/api/StopsAPI.test.js +0 -22
  204. package/common/api/HttpAPI.test.js +0 -50
  205. package/common/api/WebSocketAPI.test.js +0 -311
  206. package/common/controls/Control.test.js +0 -87
  207. package/common/layers/Layer.test.js +0 -134
  208. package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
  209. package/common/utils/createTrackerFilters.test.js +0 -79
  210. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  211. package/common/utils/removeDuplicate.test.js +0 -19
  212. package/common/utils/timeUtils.test.js +0 -10
  213. package/common/utils/trackerConfig.test.js +0 -23
  214. package/mapbox/layers/Layer.test.js +0 -182
  215. package/mapbox/layers/RealtimeLayer.test.js +0 -10
  216. package/ol/controls/CopyrightControl.test.js +0 -165
  217. package/ol/controls/RoutingControl.test.js +0 -146
  218. package/ol/controls/StopFinderControl.test.js +0 -48
  219. package/ol/layers/Layer.test.js +0 -175
  220. package/ol/layers/MapboxLayer.test.js +0 -160
  221. package/ol/layers/MapboxStyleLayer.test.js +0 -226
  222. package/ol/layers/RealtimeLayer.test.js +0 -67
  223. package/ol/layers/RoutingLayer.test.js +0 -39
  224. package/ol/layers/VectorLayer.test.js +0 -76
  225. package/ol/layers/WMSLayer.test.js +0 -57
@@ -1,124 +1,225 @@
1
- import { fromLonLat } from "ol/proj";
2
- import { unByKey } from "ol/Observable";
3
- export class UserInteractionsLayerInterface {
4
- constructor(options = {}) {
5
- }
6
- attachToMap(map) {
7
- }
8
- detachFromMap() {
9
- }
10
- activateUserInteractions() {
11
- }
12
- deactivateUserInteractions() {
13
- }
14
- onClick(callback) {
15
- }
16
- onHover(callback) {
17
- }
18
- }
19
- const UserInteractionsLayerMixin = (Base) => class extends Base {
20
- constructor(options = {}) {
21
- super(options);
22
- const {
23
- userInteractions = true,
24
- userClickInteractions = true,
25
- userHoverInteractions = true,
26
- defaultUserInteractions = true
27
- } = options;
28
- this.userInteractions = userInteractions;
29
- this.userClickInteractions = userClickInteractions;
30
- this.userHoverInteractions = userHoverInteractions;
31
- this.defaultUserInteractions = defaultUserInteractions;
32
- this.userClickCallbacks = [];
33
- this.userHoverCallbacks = [];
34
- this.userClickEventsKeys = [];
35
- this.userHoverEventsKeys = [];
36
- this.onUserClickCallback = this.onUserClickCallback.bind(this);
37
- this.onUserMoveCallback = this.onUserMoveCallback.bind(this);
38
- const { onClick, onHover } = options;
39
- if (this.userInteractions && this.userClickInteractions && onClick) {
40
- this.onClick(onClick);
41
- }
42
- if (this.userInteractions && this.userHoverInteractions && onHover) {
43
- this.onHover(onHover);
44
- }
45
- }
46
- attachToMap(map, options) {
47
- super.attachToMap(map, options);
48
- if (this.userInteractions && this.defaultUserInteractions && this.userClickInteractions && this.onFeatureClick) {
49
- this.onClick(this.onFeatureClick);
50
- }
51
- if (this.userInteractions && this.defaultUserInteractions && this.userHoverInteractions && this.onFeatureHover) {
52
- this.onHover(this.onFeatureHover);
53
- }
54
- this.listenEvents();
55
- }
56
- detachFromMap() {
57
- this.unlistenEvents();
58
- super.detachFromMap();
59
- }
60
- listenEvents() {
61
- this.unlistenEvents();
62
- this.userClickCallbacks.forEach((callback) => {
63
- this.userClickEventsKeys.push(this.on("user:click", ({ target: { features, layer, coordinate } }) => {
64
- callback(features, layer, coordinate);
65
- }));
66
- });
67
- this.userHoverCallbacks.forEach((callback) => {
68
- this.userHoverEventsKeys.push([
69
- this.on("user:hover", ({ target: { features, layer, coordinate, event } }) => {
70
- callback(features, layer, coordinate, event);
71
- })
72
- ]);
73
- });
74
- }
75
- unlistenEvents() {
76
- unByKey(this.userClickEventsKeys);
77
- unByKey(this.userHoverEventsKeys);
78
- this.userClickEventsKeys = [];
79
- this.userHoverEventsKeys = [];
80
- }
81
- onClick(callback) {
82
- this.userClickCallbacks.push(callback);
83
- this.activateUserInteractions();
84
- }
85
- onHover(callback) {
86
- this.userHoverCallbacks.push(callback);
87
- this.activateUserInteractions();
88
- }
89
- onUserClickCallback(evt) {
90
- const emptyFeatureInfo = {
91
- features: [],
92
- layer: this,
93
- coordinate: evt.coordinate || fromLonLat(evt.lngLat.toArray()),
94
- event: evt
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
95
8
  };
96
- return this.getFeatureInfoAtCoordinate(evt.coordinate).then((featureInfo) => {
97
- this.dispatchEvent({
98
- type: "user:click",
99
- target: featureInfo
100
- });
101
- return featureInfo;
102
- }).catch(() => emptyFeatureInfo);
103
- }
104
- onUserMoveCallback(evt) {
105
- const emptyFeatureInfo = {
106
- features: [],
107
- layer: this,
108
- coordinate: evt.coordinate || fromLonLat(evt.lngLat.toArray()),
109
- event: evt
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
110
15
  };
111
- return this.getFeatureInfoAtCoordinate(evt.coordinate).then((featureInfo) => {
112
- this.dispatchEvent({
113
- type: "user:hover",
114
- target: featureInfo
115
- });
116
- return featureInfo;
117
- }).catch(() => emptyFeatureInfo);
118
- }
119
- activateUserInteractions() {
120
- }
121
- deactivateUserInteractions() {
122
- }
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.UserInteractionsLayerInterface = void 0;
19
+ /* eslint-disable no-empty-function,@typescript-eslint/no-empty-function */
20
+ /* eslint-disable no-useless-constructor,@typescript-eslint/no-useless-constructor */
21
+ /* eslint-disable no-unused-vars,@typescript-eslint/no-unused-vars */
22
+ /* eslint-disable class-methods-use-this */
23
+ /* eslint-disable max-classes-per-file */
24
+ var proj_1 = require("ol/proj");
25
+ var Observable_1 = require("ol/Observable");
26
+ /**
27
+ * UserInteractionsLayerInterface.
28
+ */
29
+ var UserInteractionsLayerInterface = /** @class */ (function () {
30
+ /*
31
+ * Constructor
32
+
33
+ * @param {Object} options Layer options.
34
+ * @param {string} options.userInteractions If true, it listens for user mouse hover and click event.
35
+ * @param {string} options.userClickInteractions If true, it listens for user click event.
36
+ * @param {string} options.userHoverInteractions If true, it listens for user mouse over event.
37
+ * @param {string} options.defaultUserInteractions If true, it adds default listeners for user mouse hover and click event.
38
+ */
39
+ function UserInteractionsLayerInterface(options) {
40
+ if (options === void 0) { options = {}; }
41
+ }
42
+ /**
43
+ * Initialize the layer adding user interactions.
44
+ *
45
+ * @param {ol/Map~Map} map
46
+ */
47
+ UserInteractionsLayerInterface.prototype.attachToMap = function (map) { };
48
+ /**
49
+ * Terminate the layer unsubscribing user interactions.
50
+ */
51
+ UserInteractionsLayerInterface.prototype.detachFromMap = function () { };
52
+ /**
53
+ * Activate map listeners events.
54
+ */
55
+ UserInteractionsLayerInterface.prototype.activateUserInteractions = function () { };
56
+ /**
57
+ * Deactivaet map listeners events.
58
+ */
59
+ UserInteractionsLayerInterface.prototype.deactivateUserInteractions = function () { };
60
+ /**
61
+ * Terminate the layer unsubscribing user interactions.
62
+ */
63
+ UserInteractionsLayerInterface.prototype.onClick = function (callback) { };
64
+ /**
65
+ * Terminate the layer unsubscribing user interactions.
66
+ */
67
+ UserInteractionsLayerInterface.prototype.onHover = function (callback) { };
68
+ return UserInteractionsLayerInterface;
69
+ }());
70
+ exports.UserInteractionsLayerInterface = UserInteractionsLayerInterface;
71
+ /**
72
+ * Mixin for UserInteractionsLayerInterface. It provide onClick and onHover functions.
73
+ *
74
+ * @param {Class} Base A class to extend with {UserInteractionsLayerInterface} functionnalities.
75
+ * @return {Class} A class that implements {UserInteractionsLayerInterface} class and extends Base;
76
+ * @private
77
+ */
78
+ var UserInteractionsLayerMixin = function (Base) {
79
+ return /** @class */ (function (_super) {
80
+ __extends(class_1, _super);
81
+ function class_1(options) {
82
+ if (options === void 0) { options = {}; }
83
+ var _this = _super.call(this, options) || this;
84
+ var _a = options.userInteractions, userInteractions = _a === void 0 ? true : _a, _b = options.userClickInteractions, userClickInteractions = _b === void 0 ? true : _b, _c = options.userHoverInteractions, userHoverInteractions = _c === void 0 ? true : _c, _d = options.defaultUserInteractions, defaultUserInteractions = _d === void 0 ? true : _d;
85
+ _this.userInteractions = userInteractions;
86
+ _this.userClickInteractions = userClickInteractions;
87
+ _this.userHoverInteractions = userHoverInteractions;
88
+ _this.defaultUserInteractions = defaultUserInteractions;
89
+ _this.userClickCallbacks = [];
90
+ _this.userHoverCallbacks = [];
91
+ _this.userClickEventsKeys = [];
92
+ _this.userHoverEventsKeys = [];
93
+ _this.onUserClickCallback = _this.onUserClickCallback.bind(_this);
94
+ _this.onUserMoveCallback = _this.onUserMoveCallback.bind(_this);
95
+ // Add mouse event callbacks
96
+ var onClick = options.onClick, onHover = options.onHover;
97
+ if (_this.userInteractions && _this.userClickInteractions && onClick) {
98
+ _this.onClick(onClick);
99
+ }
100
+ if (_this.userInteractions && _this.userHoverInteractions && onHover) {
101
+ _this.onHover(onHover);
102
+ }
103
+ return _this;
104
+ }
105
+ class_1.prototype.attachToMap = function (map, options) {
106
+ _super.prototype.attachToMap.call(this, map, options);
107
+ if (this.userInteractions &&
108
+ this.defaultUserInteractions &&
109
+ this.userClickInteractions &&
110
+ this.onFeatureClick) {
111
+ this.onClick(this.onFeatureClick);
112
+ }
113
+ if (this.userInteractions &&
114
+ this.defaultUserInteractions &&
115
+ this.userHoverInteractions &&
116
+ this.onFeatureHover) {
117
+ this.onHover(this.onFeatureHover);
118
+ }
119
+ this.listenEvents();
120
+ };
121
+ class_1.prototype.detachFromMap = function () {
122
+ this.unlistenEvents();
123
+ _super.prototype.detachFromMap.call(this);
124
+ };
125
+ class_1.prototype.listenEvents = function () {
126
+ var _this = this;
127
+ this.unlistenEvents();
128
+ this.userClickCallbacks.forEach(function (callback) {
129
+ _this.userClickEventsKeys.push(_this.on('user:click', function (_a) {
130
+ var _b = _a.target, features = _b.features, layer = _b.layer, coordinate = _b.coordinate;
131
+ callback(features, layer, coordinate);
132
+ }));
133
+ });
134
+ this.userHoverCallbacks.forEach(function (callback) {
135
+ _this.userHoverEventsKeys.push(_this.on('user:hover', function (_a) {
136
+ var _b = _a.target, features = _b.features, layer = _b.layer, coordinate = _b.coordinate, event = _b.event;
137
+ callback(features, layer, coordinate, event);
138
+ }));
139
+ });
140
+ };
141
+ class_1.prototype.unlistenEvents = function () {
142
+ (0, Observable_1.unByKey)(this.userClickEventsKeys);
143
+ (0, Observable_1.unByKey)(this.userHoverEventsKeys);
144
+ this.userClickEventsKeys = [];
145
+ this.userHoverEventsKeys = [];
146
+ };
147
+ /**
148
+ * Listens to click events on the layer.
149
+ * @param {function} callback Callback function, called with the clicked
150
+ * features,
151
+ * the layer instance and the click event.
152
+ */
153
+ class_1.prototype.onClick = function (callback) {
154
+ this.userClickCallbacks.push(callback);
155
+ this.activateUserInteractions();
156
+ if (this.map) {
157
+ // If the layer is already attached to the map we reload the events
158
+ this.listenEvents();
159
+ }
160
+ };
161
+ /**
162
+ * Listens to hover events on the layer.
163
+ * @param {function} callback Callback function, called with the clicked
164
+ * features, the layer instance and the click event.
165
+ */
166
+ class_1.prototype.onHover = function (callback) {
167
+ this.userHoverCallbacks.push(callback);
168
+ this.activateUserInteractions();
169
+ if (this.map) {
170
+ // If the layer is already attached to the map we reload the events
171
+ this.listenEvents();
172
+ }
173
+ };
174
+ /**
175
+ * Function triggered when the user click the map.
176
+ * @private
177
+ */
178
+ class_1.prototype.onUserClickCallback = function (evt) {
179
+ var _this = this;
180
+ var coordinate = evt.coordinate || (0, proj_1.fromLonLat)(evt.lngLat.toArray());
181
+ var emptyFeatureInfo = {
182
+ features: [],
183
+ layer: this,
184
+ coordinate: coordinate,
185
+ event: evt,
186
+ };
187
+ return this.getFeatureInfoAtCoordinate(coordinate)
188
+ .then(function (featureInfo) {
189
+ _this.dispatchEvent({
190
+ type: 'user:click',
191
+ target: featureInfo,
192
+ });
193
+ return featureInfo;
194
+ })
195
+ .catch(function () { return emptyFeatureInfo; });
196
+ };
197
+ /**
198
+ * Function triggered when the user move the cursor.
199
+ * @private
200
+ */
201
+ class_1.prototype.onUserMoveCallback = function (evt) {
202
+ var _this = this;
203
+ var coordinate = evt.coordinate || (0, proj_1.fromLonLat)(evt.lngLat.toArray());
204
+ var emptyFeatureInfo = {
205
+ features: [],
206
+ layer: this,
207
+ coordinate: coordinate,
208
+ event: evt,
209
+ };
210
+ return this.getFeatureInfoAtCoordinate(coordinate)
211
+ .then(function (featureInfo) {
212
+ _this.dispatchEvent({
213
+ type: 'user:hover',
214
+ target: featureInfo,
215
+ });
216
+ return featureInfo;
217
+ })
218
+ .catch(function () { return emptyFeatureInfo; });
219
+ };
220
+ class_1.prototype.activateUserInteractions = function () { };
221
+ class_1.prototype.deactivateUserInteractions = function () { };
222
+ return class_1;
223
+ }(Base));
123
224
  };
124
- export default UserInteractionsLayerMixin;
225
+ exports.default = UserInteractionsLayerMixin;
@@ -0,0 +1,5 @@
1
+ export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
2
+ export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
3
+ export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
4
+ export * from "./realtimeDefaultStyle";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/styles/index.js"],"names":[],"mappings":""}
@@ -1,4 +1,24 @@
1
- export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
2
- export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
3
- export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
4
- export * from "./realtimeDefaultStyle";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.realtimeSimpleStyle = exports.realtimeDelayStyle = exports.realtimeDefaultStyle = void 0;
18
+ var realtimeDefaultStyle_1 = require("./realtimeDefaultStyle");
19
+ Object.defineProperty(exports, "realtimeDefaultStyle", { enumerable: true, get: function () { return realtimeDefaultStyle_1.default; } });
20
+ var realtimeDelayStyle_1 = require("./realtimeDelayStyle");
21
+ Object.defineProperty(exports, "realtimeDelayStyle", { enumerable: true, get: function () { return realtimeDelayStyle_1.default; } });
22
+ var realtimeSimpleStyle_1 = require("./realtimeSimpleStyle");
23
+ Object.defineProperty(exports, "realtimeSimpleStyle", { enumerable: true, get: function () { return realtimeSimpleStyle_1.default; } });
24
+ __exportStar(require("./realtimeDefaultStyle"), exports);
@@ -0,0 +1,15 @@
1
+ export function getDelayBgCanvas(origin: any, radius: any, color: any): any;
2
+ export function getDelayTextCanvas(width: any, text: any, fontSize: any, font: any, delayColor: any, delayOutlineColor?: string, pixelRatio?: number): any;
3
+ export function getCircleCanvas(origin: any, radius: any, color: any, hasStroke: any, hasDash: any, pixelRatio: any): any;
4
+ export function getTextCanvas(text: any, origin: any, textSize: any, fillColor: any, strokeColor: any, hasStroke: any, pixelRatio: any): any;
5
+ export default realtimeDefaultStyle;
6
+ /**
7
+ * A tracker style that take in account the delay.
8
+ *
9
+ * @param {*} trajectory The trajectory to render.
10
+ * @param {*} viewState The view state of the map.
11
+ * @param {*} options Some options to change the rendering
12
+ * @return a canvas
13
+ */
14
+ declare function realtimeDefaultStyle(trajectory: any, viewState: any, options: any): any;
15
+ //# sourceMappingURL=realtimeDefaultStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtimeDefaultStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeDefaultStyle.js"],"names":[],"mappings":"AAUO,4EAeN;AAUM,2JA2BN;AAUM,0HAoCN;AAUM,6IAuCN;;AAKD;;;;;;;GAOG;AACH,0FAgMC"}