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,140 +1,257 @@
1
- import BaseObject from "ol/Object";
2
- import { v4 as uuid } from "uuid";
3
- import getLayersAsFlatArray from "../utils/getLayersAsFlatArray";
4
- export default class Layer extends BaseObject {
5
- constructor(options = {}) {
6
- super();
7
- this.defineProperties(options);
8
- this.setProperties(options.properties);
9
- this.visible = options.visible === void 0 ? true : !!options.visible;
10
- this.group = options.group;
11
- this.copyrights = options.copyrights;
12
- this.children = options.children;
13
- this.on(`change:visible:group`, (evt) => {
14
- if (this.group === evt.target.group && this !== evt.target && this.visible) {
15
- this.visible = false;
16
- } else if (this.children) {
17
- this.children.forEach((child) => child.dispatchEvent(evt));
18
- }
19
- });
20
- }
21
- defineProperties(options) {
22
- const { name, key, properties, hitTolerance } = {
23
- ...options
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);
24
8
  };
25
- const uid = uuid();
26
- Object.defineProperties(this, {
27
- name: {
28
- value: name
29
- },
30
- key: {
31
- value: key || uid
32
- },
33
- group: {
34
- get: () => this.get("group"),
35
- set: (newGroup) => {
36
- this.set("group", newGroup);
37
- }
38
- },
39
- copyrights: {
40
- get: () => this.get("copyrights"),
41
- set: (newCopyrights) => {
42
- const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
43
- this.set("copyrights", arrValue || []);
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 __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
44
23
  }
45
- },
46
- options: {
47
- value: options
48
- },
49
- map: {
50
- writable: true
51
- },
52
- visible: {
53
- get: () => this.get("visible"),
54
- set: (newVisible) => {
55
- if (newVisible === this.visible) {
56
- return;
57
- }
58
- this.set("visible", newVisible);
59
- if (this.visible) {
60
- if (this.parent && !this.parent.visible) {
61
- this.parent.visible = true;
62
- }
63
- if (this.children && this.children.find((child) => child.group)) {
64
- const child = this.children.find((childd) => !!childd.group);
65
- child.visible = true;
66
- }
67
- if (this.parent && this.group) {
68
- let higherParent = this.parent;
69
- while (higherParent.parent) {
70
- higherParent = higherParent.parent;
71
- }
72
- higherParent.dispatchEvent({
73
- type: `change:visible:group`,
74
- target: this
75
- });
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var Object_1 = require("ol/Object");
30
+ var uuid_1 = require("uuid");
31
+ var getLayersAsFlatArray_1 = require("../utils/getLayersAsFlatArray");
32
+ /**
33
+ * A class representing a layer to display on map.
34
+ *
35
+ * @example
36
+ * const layer = new Layer({
37
+ * name: 'My Layer',
38
+ * });
39
+ *
40
+ * @classproperty {string} key - Identifier of the layer. Must be unique.
41
+ * @classproperty {string} name - Name of the layer
42
+ * @classproperty {string[]} copyrights - Array of copyrights.
43
+ * @classproperty {Layer[]} children - List of children layers.
44
+ * @classproperty {boolean} visible - Define if the layer is currently display on the map.
45
+ * @classproperty {boolean} disabled - Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
46
+ * @classproperty {number} hitTolerance - Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
47
+ * @classproperty {Object} properties - Custom properties.
48
+ * @classproperty {ol/Map~Map|mapboxgl.Map} map - The map where the layer is displayed.
49
+ */
50
+ var Layer = /** @class */ (function (_super) {
51
+ __extends(Layer, _super);
52
+ /**
53
+ * Constructor
54
+ *
55
+ * @param {Object} options
56
+ * @param {string} [options.key=uuid()] Identifier of the layer. Muste be unique. Default use a generated uuid.
57
+ * @param {string} [options.name] Name of the layer.
58
+ * @param {string[]} [options.copyrights] Array of copyrights.
59
+ * @param {Array<Layer>} [options.children=[]] Sublayers, all child layers will have a parent property associated to this layer.
60
+ * @param {boolean} [options.visible=true] Define if the layer is currently display on the map.
61
+ * @param {boolean} [options.disabled=false] Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
62
+ * @param {number} [options.hitTolerance=5] Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
63
+ * @param {Object} [options.properties={}] Application-specific layer properties.
64
+ */
65
+ function Layer(options) {
66
+ if (options === void 0) { options = {}; }
67
+ var _this = _super.call(this) || this;
68
+ _this.defineProperties(options);
69
+ _this.setProperties(options.properties);
70
+ _this.visible = options.visible === undefined ? true : !!options.visible;
71
+ _this.group = options.group;
72
+ _this.copyrights = options.copyrights;
73
+ _this.children = options.children;
74
+ // Listen for group visiblity change
75
+ // if a layer from a group is newly visible we hide the others.
76
+ _this.on("change:visible:group", function (evt) {
77
+ // We hide layer of the same group
78
+ if (_this.group === evt.target.group &&
79
+ _this !== evt.target &&
80
+ _this.visible) {
81
+ _this.visible = false;
82
+ // Propagate event to parent
76
83
  }
77
- } else if (!this.visible) {
78
- if (this.parent && this.parent.visible && !this.parent.children.find((child) => child.visible)) {
79
- this.parent.visible = false;
84
+ else if (_this.children) {
85
+ _this.children.forEach(function (child) { return child.dispatchEvent(evt); });
80
86
  }
81
- }
82
- }
83
- },
84
- disabled: {
85
- get: () => this.get("disabled"),
86
- set: (newValue) => {
87
- this.set("disabled", newValue);
88
- }
89
- },
90
- parent: {
91
- value: null,
92
- writable: true
93
- },
94
- children: {
95
- get: () => this.get("children") || [],
96
- set: (newValue) => {
97
- (this.children || []).forEach((child) => {
98
- child.parent = null;
99
- });
100
- if (Array.isArray(newValue)) {
101
- newValue.forEach((child) => {
102
- child.parent = this;
87
+ });
88
+ return _this;
89
+ }
90
+ /**
91
+ * Define layer's properties that needs custom get and set.
92
+ *
93
+ * @ignore
94
+ */
95
+ Layer.prototype.defineProperties = function (options) {
96
+ var _this = this;
97
+ var _a = __assign({}, options), name = _a.name, key = _a.key, properties = _a.properties, hitTolerance = _a.hitTolerance;
98
+ var uid = (0, uuid_1.v4)();
99
+ Object.defineProperties(this, {
100
+ /* Layer's information properties */
101
+ name: {
102
+ value: name,
103
+ },
104
+ key: {
105
+ value: key || uid,
106
+ },
107
+ group: {
108
+ get: function () { return _this.get('group'); },
109
+ set: function (newGroup) {
110
+ _this.set('group', newGroup);
111
+ },
112
+ },
113
+ copyrights: {
114
+ get: function () { return _this.get('copyrights'); },
115
+ set: function (newCopyrights) {
116
+ var arrValue = newCopyrights && !Array.isArray(newCopyrights)
117
+ ? [newCopyrights]
118
+ : newCopyrights;
119
+ _this.set('copyrights', arrValue || []);
120
+ },
121
+ },
122
+ // options is used for clone function.
123
+ options: {
124
+ value: options,
125
+ },
126
+ map: {
127
+ writable: true,
128
+ },
129
+ /* Layer's state properties */
130
+ visible: {
131
+ get: function () { return _this.get('visible'); },
132
+ set: function (newVisible) {
133
+ if (newVisible === _this.visible) {
134
+ return;
135
+ }
136
+ _this.set('visible', newVisible);
137
+ if (_this.visible) {
138
+ if (_this.parent && !_this.parent.visible) {
139
+ _this.parent.visible = true;
140
+ }
141
+ if (_this.children && _this.children.find(function (child) { return child.group; })) {
142
+ var child = _this.children.find(function (childd) { return !!childd.group; });
143
+ // Make visible only radioGroup layers
144
+ child.visible = true;
145
+ }
146
+ // Warn the same group that a new layer is visible
147
+ if (_this.parent && _this.group) {
148
+ // We search for the higher parent then it will dispatch to all the tree.
149
+ var higherParent = _this.parent;
150
+ while (higherParent.parent) {
151
+ higherParent = higherParent.parent;
152
+ }
153
+ higherParent.dispatchEvent({
154
+ type: "change:visible:group",
155
+ target: _this,
156
+ });
157
+ }
158
+ }
159
+ else if (!_this.visible) {
160
+ if (_this.parent &&
161
+ _this.parent.visible &&
162
+ !_this.parent.children.find(function (child) { return child.visible; })) {
163
+ _this.parent.visible = false;
164
+ }
165
+ }
166
+ },
167
+ },
168
+ disabled: {
169
+ get: function () { return _this.get('disabled'); },
170
+ set: function (newValue) {
171
+ _this.set('disabled', newValue);
172
+ },
173
+ },
174
+ /* Layer's hierarchy properties */
175
+ parent: {
176
+ value: null,
177
+ writable: true,
178
+ },
179
+ children: {
180
+ get: function () { return _this.get('children') || []; },
181
+ set: function (newValue) {
182
+ (_this.children || []).forEach(function (child) {
183
+ // eslint-disable-next-line no-param-reassign
184
+ child.parent = null;
185
+ });
186
+ if (Array.isArray(newValue)) {
187
+ newValue.forEach(function (child) {
188
+ // eslint-disable-next-line no-param-reassign
189
+ child.parent = _this;
190
+ });
191
+ }
192
+ _this.set('children', newValue || []);
193
+ },
194
+ },
195
+ /* Layer's query properties */
196
+ hitTolerance: {
197
+ value: hitTolerance || 5,
198
+ writable: true,
199
+ },
200
+ /* Custom app specific properties */
201
+ properties: {
202
+ value: __assign({}, (properties || {})),
203
+ },
204
+ });
205
+ };
206
+ /**
207
+ * Initialize the layer with the map passed in parameters.
208
+ *
209
+ * @param {ol/Map~Map|mapboxgl.Map} map A map.
210
+ */
211
+ Layer.prototype.attachToMap = function (map) {
212
+ this.detachFromMap();
213
+ /** @ignore */
214
+ this.map = map;
215
+ if (this.children) {
216
+ this.children.forEach(function (child) {
217
+ child.attachToMap(map);
103
218
  });
104
- }
105
- this.set("children", newValue || []);
106
219
  }
107
- },
108
- hitTolerance: {
109
- value: hitTolerance || 5,
110
- writable: true
111
- },
112
- properties: {
113
- value: { ...properties || {} }
114
- }
115
- });
116
- }
117
- attachToMap(map) {
118
- this.detachFromMap();
119
- this.map = map;
120
- if (this.children) {
121
- this.children.forEach((child) => {
122
- child.attachToMap(map);
123
- });
124
- }
125
- }
126
- detachFromMap() {
127
- this.map = null;
128
- }
129
- getFeatureInfoAtCoordinate(coordinate, options) {
130
- console.error("getFeatureInfoAtCoordinate must be implemented by inheriting layers", this.key);
131
- return Promise.resolve({
132
- layer: this,
133
- features: [],
134
- coordinate
135
- });
136
- }
137
- flat() {
138
- return getLayersAsFlatArray(this);
139
- }
140
- }
220
+ };
221
+ /**
222
+ * Terminate what was initialized in init function. Remove layer, events...
223
+ */
224
+ // eslint-disable-next-line class-methods-use-this
225
+ Layer.prototype.detachFromMap = function () {
226
+ /** @ignore */
227
+ this.map = null;
228
+ };
229
+ /**
230
+ * Request feature information for a given coordinate.
231
+ * This function must be implemented by inheriting layers.
232
+ *
233
+ * @param {ol/coordinate~Coordinate} coordinate Coordinate.
234
+ * @param {Object} options Some options. See child classes to see which are supported.
235
+ * @return {Promise<FeatureInfo>} An empty response.
236
+ */
237
+ // eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
238
+ Layer.prototype.getFeatureInfoAtCoordinate = function (coordinate, options) {
239
+ // eslint-disable-next-line no-console
240
+ console.error('getFeatureInfoAtCoordinate must be implemented by inheriting layers', this.key);
241
+ // This layer returns no feature info.
242
+ // The function is implemented by inheriting layers.
243
+ return Promise.resolve({
244
+ layer: this,
245
+ features: [],
246
+ coordinate: coordinate,
247
+ });
248
+ };
249
+ /**
250
+ * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
251
+ */
252
+ Layer.prototype.flat = function () {
253
+ return (0, getLayersAsFlatArray_1.default)(this);
254
+ };
255
+ return Layer;
256
+ }(Object_1.default));
257
+ exports.default = Layer;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright control interface.
3
+ *
4
+ */
5
+ export class CopyrightInterface {
6
+ /**
7
+ * Return an array of layer's copyright.
8
+ *
9
+ * @return {String[]} A list of copyrights to render.
10
+ */
11
+ getCopyrights(): string[];
12
+ }
13
+ export default CopyrightMixin;
14
+ /**
15
+ * Mixin for CopyrightInterface.
16
+ *
17
+ * @param {Class} Base A class to extend with {CopyrightInterface} functionnalities.
18
+ * @return {Class} A class that implements <CopyrightInterface> class and extends Base;
19
+ * @private
20
+ */
21
+ declare function CopyrightMixin(Base: Class): Class;
22
+ //# sourceMappingURL=CopyrightMixin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopyrightMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/CopyrightMixin.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;OAIG;IACH,iBAFY,QAAQ,CAEF;CACnB;;AAED;;;;;;GAMG;AACH,oDAsBG"}
@@ -1,24 +1,72 @@
1
- export class CopyrightInterface {
2
- getCopyrights() {
3
- }
4
- }
5
- const CopyrightMixin = (Base) => class extends Base {
6
- render() {
7
- if (!this.element) {
8
- return;
1
+ "use strict";
2
+ /* eslint-disable class-methods-use-this */
3
+ /* eslint-disable max-classes-per-file */
4
+ var __extends = (this && this.__extends) || (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics = Object.setPrototypeOf ||
7
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
+ return extendStatics(d, b);
10
+ };
11
+ return function (d, b) {
12
+ if (typeof b !== "function" && b !== null)
13
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.CopyrightInterface = void 0;
21
+ /**
22
+ * Copyright control interface.
23
+ *
24
+ */
25
+ var CopyrightInterface = /** @class */ (function () {
26
+ function CopyrightInterface() {
9
27
  }
10
- this.element.innerHTML = this.active ? this.getCopyrights().join(" | ") : "";
11
- }
12
- createDefaultElement() {
13
- this.element = document.createElement("div");
14
- this.element.id = "mbt-copyright";
15
- Object.assign(this.element.style, {
16
- position: "absolute",
17
- bottom: 0,
18
- right: 0,
19
- fontSize: ".8rem",
20
- padding: "0 10px"
21
- });
22
- }
28
+ /**
29
+ * Return an array of layer's copyright.
30
+ *
31
+ * @return {String[]} A list of copyrights to render.
32
+ */
33
+ CopyrightInterface.prototype.getCopyrights = function () { };
34
+ return CopyrightInterface;
35
+ }());
36
+ exports.CopyrightInterface = CopyrightInterface;
37
+ /**
38
+ * Mixin for CopyrightInterface.
39
+ *
40
+ * @param {Class} Base A class to extend with {CopyrightInterface} functionnalities.
41
+ * @return {Class} A class that implements <CopyrightInterface> class and extends Base;
42
+ * @private
43
+ */
44
+ var CopyrightMixin = function (Base) {
45
+ return /** @class */ (function (_super) {
46
+ __extends(class_1, _super);
47
+ function class_1() {
48
+ return _super !== null && _super.apply(this, arguments) || this;
49
+ }
50
+ class_1.prototype.render = function () {
51
+ if (!this.element) {
52
+ return;
53
+ }
54
+ this.element.innerHTML = this.active
55
+ ? this.getCopyrights().join(' | ')
56
+ : '';
57
+ };
58
+ class_1.prototype.createDefaultElement = function () {
59
+ this.element = document.createElement('div');
60
+ this.element.id = 'mbt-copyright';
61
+ Object.assign(this.element.style, {
62
+ position: 'absolute',
63
+ bottom: 0,
64
+ right: 0,
65
+ fontSize: '.8rem',
66
+ padding: '0 10px',
67
+ });
68
+ };
69
+ return class_1;
70
+ }(Base));
23
71
  };
24
- export default CopyrightMixin;
72
+ exports.default = CopyrightMixin;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * MapboxLayerInterface
3
+ */
4
+ export class MapboxLayerInterface {
5
+ /**
6
+ * Return the render function function for the ol layer.
7
+ *
8
+ */
9
+ getOlLayerRender(): void;
10
+ /**
11
+ * Return the Class to instanciate for the mapbox map.
12
+ *
13
+ * @return {mapboxgl.Map|maplibregl.Map} map
14
+ */
15
+ getMapboxMapClass(): mapboxgl.Map | maplibregl.Map;
16
+ }
17
+ export default MapboxLayerMixin;
18
+ /**
19
+ * Mixin for MapboxLayerLayerInterface.
20
+ * It's used to share code between Mapbox and Maplibre layers without importing both libs
21
+ *
22
+ * @param {Class} Base A class to extend with {MapboxLayerLayerInterface} functionnalities.
23
+ * @return {Class} A class that implements {MapboxLayerLayerInterface} class and extends Base;
24
+ * @private
25
+ */
26
+ declare function MapboxLayerMixin(Base: Class): Class;
27
+ //# sourceMappingURL=MapboxLayerMixin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapboxLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/MapboxLayerMixin.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IACE;;;OAGG;IAEH,yBAAqB;IAErB;;;;OAIG;IAEH,qBAHY,eAAa,cAAc,CAGjB;CACvB;;AAED;;;;;;;GAOG;AACH,sDA6MG"}