mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.21

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 (125) hide show
  1. package/api/HttpAPI.d.ts +20 -0
  2. package/api/HttpAPI.js +0 -11
  3. package/api/RealtimeAPI.d.ts +404 -0
  4. package/api/RealtimeAPI.js +342 -276
  5. package/api/RoutingAPI.d.ts +47 -0
  6. package/api/RoutingAPI.js +17 -7
  7. package/api/StopsAPI.d.ts +44 -0
  8. package/api/StopsAPI.js +16 -10
  9. package/api/WebSocketAPI.d.ts +147 -0
  10. package/api/WebSocketAPI.js +164 -164
  11. package/api/index.d.ts +3 -0
  12. package/api/index.js +1 -1
  13. package/api/typedefs.d.ts +76 -0
  14. package/api/typedefs.js +27 -42
  15. package/common/controls/StopFinderControlCommon.d.ts +53 -0
  16. package/common/controls/StopFinderControlCommon.js +31 -31
  17. package/common/index.d.ts +2 -0
  18. package/common/index.js +1 -1
  19. package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
  20. package/common/mixins/RealtimeLayerMixin.js +401 -393
  21. package/common/styles/index.d.ts +4 -0
  22. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  23. package/common/styles/realtimeDefaultStyle.js +6 -6
  24. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  25. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  26. package/common/styles/realtimeHeadingStyle.js +5 -5
  27. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  28. package/common/typedefs.d.ts +219 -0
  29. package/common/typedefs.js +7 -1
  30. package/common/utils/compareDepartures.d.ts +10 -0
  31. package/common/utils/compareDepartures.js +2 -2
  32. package/common/utils/constants.d.ts +5 -0
  33. package/common/utils/createCanvas.d.ts +10 -0
  34. package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
  35. package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
  36. package/common/utils/createRealtimeFilters.d.ts +12 -0
  37. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  38. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  39. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  40. package/common/utils/getLayersAsFlatArray.js +5 -1
  41. package/common/utils/getMapGlCopyrights.d.ts +17 -0
  42. package/common/utils/getMapGlCopyrights.js +3 -3
  43. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  44. package/common/utils/getRealtimeModeSuffix.js +1 -0
  45. package/common/utils/getUrlWithParams.d.ts +8 -0
  46. package/common/utils/getVehiclePosition.d.ts +17 -0
  47. package/common/utils/getVehiclePosition.js +9 -3
  48. package/common/utils/index.d.ts +16 -0
  49. package/common/utils/realtimeConfig.d.ts +64 -0
  50. package/common/utils/removeDuplicate.d.ts +9 -0
  51. package/common/utils/renderTrajectories.d.ts +16 -0
  52. package/common/utils/renderTrajectories.js +6 -6
  53. package/common/utils/sortAndFilterDepartures.d.ts +15 -0
  54. package/common/utils/sortAndFilterDepartures.js +1 -1
  55. package/common/utils/sortByDelay.d.ts +3 -0
  56. package/common/utils/sortByDelay.js +5 -1
  57. package/common/utils/timeUtils.d.ts +23 -0
  58. package/common/utils/toMercatorExtent.d.ts +5 -0
  59. package/iife.d.ts +2 -0
  60. package/index.d.ts +9 -0
  61. package/maplibre/controls/CopyrightControl.d.ts +35 -0
  62. package/maplibre/controls/index.d.ts +1 -0
  63. package/maplibre/index.d.ts +5 -0
  64. package/maplibre/layers/Layer.d.ts +28 -0
  65. package/maplibre/layers/Layer.js +1 -1
  66. package/maplibre/layers/RealtimeLayer.d.ts +181 -0
  67. package/maplibre/layers/RealtimeLayer.js +29 -5
  68. package/maplibre/layers/index.d.ts +2 -0
  69. package/maplibre/utils/getMercatorResolution.d.ts +7 -0
  70. package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
  71. package/maplibre/utils/getSourceCoordinates.js +5 -5
  72. package/maplibre/utils/index.d.ts +2 -0
  73. package/mbt.js +22103 -14430
  74. package/mbt.js.map +4 -4
  75. package/mbt.min.js +61 -58
  76. package/mbt.min.js.map +4 -4
  77. package/ol/controls/CopyrightControl.d.ts +31 -0
  78. package/ol/controls/CopyrightControl.js +18 -8
  79. package/ol/controls/RoutingControl.d.ts +202 -0
  80. package/ol/controls/RoutingControl.js +220 -219
  81. package/ol/controls/StopFinderControl.d.ts +37 -0
  82. package/ol/controls/StopFinderControl.js +4 -1
  83. package/ol/controls/index.d.ts +3 -0
  84. package/ol/index.d.ts +7 -0
  85. package/ol/index.js +1 -0
  86. package/ol/layers/Layer.d.ts +101 -0
  87. package/ol/layers/Layer.js +25 -0
  88. package/ol/layers/MaplibreLayer.d.ts +160 -0
  89. package/ol/layers/MaplibreLayer.js +97 -27
  90. package/ol/layers/MaplibreStyleLayer.d.ts +237 -0
  91. package/ol/layers/MaplibreStyleLayer.js +291 -267
  92. package/ol/layers/RealtimeLayer.d.ts +283 -0
  93. package/ol/layers/RealtimeLayer.js +143 -128
  94. package/ol/layers/VectorLayer.d.ts +18 -0
  95. package/ol/layers/VectorLayer.js +31 -0
  96. package/ol/layers/index.d.ts +5 -0
  97. package/ol/layers/index.js +3 -0
  98. package/ol/mixins/MobilityLayerMixin.d.ts +96 -0
  99. package/ol/mixins/MobilityLayerMixin.js +1 -4
  100. package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
  101. package/ol/mixins/PropertiesLayerMixin.js +112 -140
  102. package/ol/mixins/index.d.ts +1 -0
  103. package/ol/mixins/index.js +2 -0
  104. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
  105. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  106. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
  107. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  108. package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
  109. package/ol/renderers/RealtimeLayerRenderer.js +58 -53
  110. package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
  111. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  112. package/ol/styles/index.d.ts +3 -0
  113. package/ol/styles/routingStyle.d.ts +4 -0
  114. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
  115. package/ol/utils/getFeatureInfoAtCoordinate.js +12 -18
  116. package/ol/utils/index.d.ts +1 -0
  117. package/package.json +31 -31
  118. package/setupTests.d.ts +1 -0
  119. package/setupTests.js +3 -4
  120. package/types/common.d.ts +55 -48
  121. package/types/index.d.ts +1 -1
  122. package/types/realtime.d.ts +91 -93
  123. package/types/routing.d.ts +60 -60
  124. package/types/stops.d.ts +62 -62
  125. package/ol/layers/MapGlLayer.js +0 -142
@@ -0,0 +1,135 @@
1
+ import { Map } from 'ol';
2
+ import { EventsKey } from 'ol/events';
3
+ import { Layer } from 'ol/layer';
4
+ import type { Options } from 'ol/layer/Layer';
5
+ import type { Layerable } from './MobilityLayerMixin';
6
+ export type PropertiesLayerMixinOptions = {
7
+ children?: any[];
8
+ copyrights?: string[];
9
+ disabled?: boolean;
10
+ group?: string;
11
+ hitTolerance?: number;
12
+ key?: string;
13
+ map?: Map;
14
+ name?: string;
15
+ properties?: Record<string, any>;
16
+ visible?: boolean;
17
+ } & Options & Record<string, any>;
18
+ /**
19
+ * This mixin adds some properties to access ol custom properties easily.
20
+ */
21
+ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
22
+ new (...args: any[]): {
23
+ olEventsKeys: EventsKey[];
24
+ options?: PropertiesLayerMixinOptions;
25
+ /**
26
+ * Initialize the layer with the map passed in parameters.
27
+ *
28
+ * @param {ol/Map~Map} map A map.
29
+ */
30
+ attachToMap(map: Map): void;
31
+ /**
32
+ * Terminate what was initialized in init function. Remove layer, events...
33
+ */
34
+ detachFromMap(): void;
35
+ /**
36
+ * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
37
+ * @deprecated
38
+ */
39
+ flat(): any[];
40
+ /** @private */
41
+ onChildrenChange(oldValue: Layer[]): void;
42
+ setMapInternal(map: Map): void;
43
+ /** @deprecated */
44
+ children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
45
+ /** @deprecated */
46
+ get copyrights(): string;
47
+ /** @deprecated */
48
+ set copyrights(newCopyrights: string | string[]);
49
+ /** @deprecated */
50
+ disabled: boolean;
51
+ /** @deprecated */
52
+ /** @deprecated */
53
+ readonly group: string;
54
+ /** @deprecated */
55
+ readonly hitTolerance: number;
56
+ readonly key: string;
57
+ readonly map: Map;
58
+ /** @deprecated */
59
+ readonly name: string;
60
+ /** @deprecated */
61
+ olLayer: Layer;
62
+ /** @deprecated */
63
+ parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
64
+ /** @deprecated */
65
+ visible: boolean;
66
+ on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
67
+ once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
68
+ un: import("ol/layer/Layer").LayerOnSignature<void>;
69
+ render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
70
+ getSource: () => import("ol/source").Source | null;
71
+ getRenderSource: () => import("ol/source").Source | null;
72
+ getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
73
+ getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
74
+ isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
75
+ getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
76
+ unrender: () => void;
77
+ getDeclutter: () => string;
78
+ renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
79
+ renderDeferred: (frameState: import("ol/Map").FrameState) => void;
80
+ getMapInternal: () => import("ol/Map").default | null;
81
+ setMap: (map: import("ol/Map").default | null) => void;
82
+ setSource: (source: import("ol/source").Source | null) => void;
83
+ getRenderer: () => import("ol/renderer/Layer").default<any> | null;
84
+ hasRenderer: () => boolean;
85
+ getBackground: () => import("ol/layer/Base").BackgroundColor | false;
86
+ getClassName: () => string;
87
+ getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
88
+ getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
89
+ getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
90
+ getExtent: () => import("ol/extent").Extent | undefined;
91
+ getMaxResolution: () => number;
92
+ getMinResolution: () => number;
93
+ getMinZoom: () => number;
94
+ getMaxZoom: () => number;
95
+ getOpacity: () => number;
96
+ getSourceState: () => import("ol/source/Source").State;
97
+ getVisible: () => boolean;
98
+ getZIndex: () => number | undefined;
99
+ setBackground: (background?: import("ol/layer/Base").BackgroundColor | undefined) => void;
100
+ setExtent: (extent: import("ol/extent").Extent | undefined) => void;
101
+ setMaxResolution: (maxResolution: number) => void;
102
+ setMinResolution: (minResolution: number) => void;
103
+ setMaxZoom: (maxZoom: number) => void;
104
+ setMinZoom: (minZoom: number) => void;
105
+ setOpacity: (opacity: number) => void;
106
+ setVisible: (visible: boolean) => void;
107
+ setZIndex: (zindex: number) => void;
108
+ get: (key: string) => any;
109
+ getKeys: () => Array<string>;
110
+ getProperties: () => {
111
+ [x: string]: any;
112
+ };
113
+ getPropertiesInternal: () => {
114
+ [x: string]: any;
115
+ } | null;
116
+ hasProperties: () => boolean;
117
+ notify: (key: string, oldValue: any) => void;
118
+ addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
119
+ removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
120
+ set: (key: string, value: any, silent?: boolean | undefined) => void;
121
+ setProperties: (values: {
122
+ [x: string]: any;
123
+ }, silent?: boolean | undefined) => void;
124
+ unset: (key: string, silent?: boolean | undefined) => void;
125
+ changed: () => void;
126
+ getRevision: () => number;
127
+ addEventListener: (type: string, listener: import("ol/events").Listener) => void;
128
+ dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
129
+ getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
130
+ hasListener: (type?: string | undefined) => boolean;
131
+ removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
132
+ dispose: () => void;
133
+ };
134
+ } & TBase;
135
+ export default PropertiesLayerMixin;
@@ -1,43 +1,132 @@
1
- import BaseEvent from 'ol/events/Event';
1
+ // eslint-disable-next-line max-classes-per-file
2
+ import debounce from 'lodash.debounce';
2
3
  import { getUid } from 'ol';
3
4
  import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
5
+ let deprecated = () => { };
6
+ if (typeof window !== 'undefined' &&
7
+ new URLSearchParams(window.location.search).get('deprecated')) {
8
+ deprecated = debounce((message) => {
9
+ // eslint-disable-next-line no-console
10
+ console.warn(message);
11
+ }, 1000);
12
+ }
4
13
  /**
5
- * This mixin adds some properties to access some ol properties easily ansd also
6
- * the management of a hierarchy of layers using children, parent and group property.
14
+ * This mixin adds some properties to access ol custom properties easily.
7
15
  */
8
16
  function PropertiesLayerMixin(Base) {
9
- return class extends Base {
17
+ return class PropertiesLayer extends Base {
18
+ constructor(...args) {
19
+ var _a;
20
+ const options = args[0];
21
+ super(options);
22
+ this.olEventsKeys = [];
23
+ this.options = {};
24
+ if (options.properties) {
25
+ deprecated("Deprecated. Don't use properties options. Pass the values directly in options object.");
26
+ this.setProperties(options.properties);
27
+ }
28
+ (_a = this.olEventsKeys) === null || _a === void 0 ? void 0 : _a.push(
29
+ // Update parent property
30
+ this.on('propertychange', (evt) => {
31
+ if (evt.key === 'children') {
32
+ this.onChildrenChange(evt.oldValue);
33
+ }
34
+ }));
35
+ this.options = options;
36
+ this.set('children', options.children || []); // Trigger the on children change event
37
+ }
38
+ /**
39
+ * Initialize the layer with the map passed in parameters.
40
+ *
41
+ * @param {ol/Map~Map} map A map.
42
+ */
43
+ attachToMap(map) {
44
+ // @ts-expect-error attachToMap not necessarily exists
45
+ (super.attachToMap || (() => { }))(map);
46
+ (this.get('children') || []).forEach((child) => {
47
+ map.addLayer(child);
48
+ });
49
+ }
50
+ /**
51
+ * Terminate what was initialized in init function. Remove layer, events...
52
+ */
53
+ detachFromMap() {
54
+ (this.get('children') || []).forEach((child) => {
55
+ this.map.removeLayer(child);
56
+ });
57
+ // @ts-expect-error detachToMap not necessarily exists
58
+ (super.detachFromMap || (() => { }))();
59
+ }
60
+ /**
61
+ * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
62
+ * @deprecated
63
+ */
64
+ flat() {
65
+ deprecated('Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead.');
66
+ return getLayersAsFlatArray(this);
67
+ }
68
+ /** @private */
69
+ onChildrenChange(oldValue) {
70
+ // Set the parent property
71
+ (oldValue || []).forEach((child) => {
72
+ child.set('parent', undefined);
73
+ });
74
+ (this.get('children') || []).forEach((child) => {
75
+ child.set('parent', this);
76
+ });
77
+ }
78
+ // @ts-expect-error - this is a mixin
79
+ setMapInternal(map) {
80
+ super.setMapInternal(map);
81
+ if (map) {
82
+ this.attachToMap(map);
83
+ }
84
+ else {
85
+ this.detachFromMap();
86
+ }
87
+ }
88
+ /** @deprecated */
10
89
  get children() {
90
+ deprecated("Layer.children is deprecated. Use the Layer.get('children') method instead.");
11
91
  return this.get('children') || [];
12
92
  }
93
+ /** @deprecated */
13
94
  set children(newValue) {
95
+ deprecated("Layer.children is deprecated. Use the Layer.set('children', children) method instead.");
14
96
  this.set('children', newValue || []);
15
97
  }
98
+ /** @deprecated */
16
99
  get copyrights() {
17
- // eslint-disable-next-line no-console
18
- console.warn('Deprecated. Use the source object to get the attributions');
100
+ deprecated('Layer.copyrights is deprecated. Get the attributions from the source object');
19
101
  return this.get('copyrights');
20
102
  }
103
+ /** @deprecated */
21
104
  set copyrights(newCopyrights) {
22
- // eslint-disable-next-line no-console
23
- console.warn('Deprecated. Use the source object to set the attributions');
105
+ deprecated('Layer.copyrights is deprecated. Set the attributions to the source object.');
24
106
  const arrValue = newCopyrights && !Array.isArray(newCopyrights)
25
107
  ? [newCopyrights]
26
108
  : newCopyrights;
27
109
  this.set('copyrights', arrValue || []);
28
110
  }
111
+ /** @deprecated */
29
112
  get disabled() {
113
+ deprecated("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead.");
30
114
  return this.get('disabled');
31
115
  }
116
+ /** @deprecated */
32
117
  set disabled(newValue) {
118
+ deprecated("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead.");
33
119
  this.set('disabled', newValue);
34
120
  }
121
+ /** @deprecated */
122
+ /** @deprecated */
35
123
  get group() {
124
+ deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
36
125
  return this.get('group');
37
126
  }
127
+ /** @deprecated */
38
128
  get hitTolerance() {
39
- // eslint-disable-next-line no-console
40
- console.warn('Deprecated. Pass the pixelTolerance when you request the features.');
129
+ deprecated('Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features.');
41
130
  return this.get('hitTolerance') || 5;
42
131
  }
43
132
  get key() {
@@ -46,157 +135,40 @@ function PropertiesLayerMixin(Base) {
46
135
  get map() {
47
136
  return this.getMapInternal();
48
137
  }
138
+ /** @deprecated */
49
139
  get name() {
140
+ deprecated("Layer.name is deprecated. Use the Layer.get('name') method instead.");
50
141
  return this.get('name');
51
142
  }
143
+ /** @deprecated */
52
144
  get olLayer() {
53
- // eslint-disable-next-line no-console
54
- console.warn("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object.");
145
+ deprecated("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object.");
55
146
  return this;
56
147
  }
57
148
  // eslint-disable-next-line class-methods-use-this
58
149
  set olLayer(newValue) {
59
- // eslint-disable-next-line no-console
60
- console.log('Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
150
+ deprecated('Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.');
61
151
  }
152
+ /** @deprecated */
62
153
  get parent() {
154
+ deprecated("Layer.parent is deprecated. Use the Layer.get('parent') method instead.");
63
155
  return this.get('parent');
64
156
  }
157
+ /** @deprecated */
65
158
  set parent(newValue) {
159
+ deprecated("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead.");
66
160
  this.set('parent', newValue);
67
161
  }
162
+ /** @deprecated */
68
163
  get visible() {
164
+ deprecated('Layer.visible is deprecated. Use the Layer.getVisible() method instead.');
69
165
  return this.getVisible();
70
166
  }
167
+ /** @deprecated */
71
168
  set visible(newValue) {
169
+ deprecated('Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead.');
72
170
  this.setVisible(newValue);
73
171
  }
74
- constructor(options) {
75
- var _a;
76
- super(options);
77
- this.options = {};
78
- this.olListenersKeys = [];
79
- if (options.properties) {
80
- // eslint-disable-next-line no-console
81
- console.warn("Deprecated. Don't use properties options. Pass the values directly in options object.");
82
- this.setProperties(options.properties);
83
- }
84
- (_a = this.olListenersKeys) === null || _a === void 0 ? void 0 : _a.push(
85
- // Update parent property
86
- this.on('propertychange', (evt) => {
87
- if (evt.key === 'children') {
88
- this.onChildrenChange(evt.oldValue);
89
- }
90
- }),
91
- // Manage group visiblity
92
- this.on('change:visible', () => {
93
- this.onVisibleChange();
94
- }),
95
- // Listen for group visiblity change
96
- // if a layer from a group is newly visible we hide the others.
97
- // @ts-ignore
98
- this.on(`change:visible:group`, (evt) => {
99
- // We hide layer of the same group
100
- if (this.group === evt.target.group &&
101
- this !== evt.target &&
102
- this.visible) {
103
- this.visible = false;
104
- // Propagate event to parent
105
- }
106
- else if (this.children) {
107
- this.children.forEach((child) => child.dispatchEvent(evt));
108
- }
109
- }));
110
- this.options = options;
111
- this.children = options.children || []; // Trigger the on children change event
112
- }
113
- setMapInternal(map) {
114
- super.setMapInternal(map);
115
- if (map) {
116
- this.attachToMap(map);
117
- }
118
- else {
119
- this.detachFromMap();
120
- }
121
- }
122
- /** @private */
123
- onChildrenChange(oldValue) {
124
- // Set the parent property
125
- (oldValue || []).forEach((child) => {
126
- child.set('parent', undefined);
127
- });
128
- (this.children || []).forEach((child) => {
129
- child.set('parent', this);
130
- });
131
- }
132
- /** @private */
133
- onVisibleChange() {
134
- const parent = this.get('parent');
135
- const children = this.get('children') || [];
136
- if (this.getVisible()) {
137
- const group = this.get('group');
138
- // We make the parent visible
139
- if (parent) {
140
- parent.setVisible(true);
141
- }
142
- // If children doesn't contain any visible layers, we display all children.
143
- if (children && !children.some((child) => child.getVisible())) {
144
- children.forEach((child) => {
145
- child.setVisible(true);
146
- });
147
- }
148
- // Warn the same group that a new layer is visible
149
- if (parent && group) {
150
- // We search for the higher parent then it will dispatch to all the tree.
151
- let higherParent = parent;
152
- while (higherParent.get('parent')) {
153
- higherParent = higherParent.get('parent');
154
- }
155
- const evt = new BaseEvent(`change:visible:group`);
156
- evt.target = this;
157
- higherParent.dispatchEvent(evt);
158
- }
159
- }
160
- else {
161
- // We hide all the children
162
- children.forEach((child) => {
163
- child.setVisible(false);
164
- });
165
- // If the parent has no more visible child we also hide it.
166
- if ((parent === null || parent === void 0 ? void 0 : parent.getVisible()) &&
167
- !(parent === null || parent === void 0 ? void 0 : parent.get('children').find((child) => child.getVisible()))) {
168
- parent.setVisible(false);
169
- }
170
- }
171
- }
172
- /**
173
- * Initialize the layer with the map passed in parameters.
174
- *
175
- * @param {ol/Map~Map} map A map.
176
- */
177
- attachToMap(map) {
178
- // @ts-ignore
179
- (super.attachToMap || (() => { }))(map);
180
- (this.get('children') || []).forEach((child) => {
181
- map.addLayer(child);
182
- });
183
- }
184
- /**
185
- * Terminate what was initialized in init function. Remove layer, events...
186
- */
187
- detachFromMap() {
188
- (this.get('children') || []).forEach((child) => {
189
- this.map.removeLayer(child);
190
- });
191
- // @ts-ignore
192
- (super.detachFromMap || (() => { }))(map);
193
- }
194
- /**
195
- * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
196
- */
197
- flat() {
198
- return getLayersAsFlatArray(this);
199
- }
200
172
  };
201
173
  }
202
174
  export default PropertiesLayerMixin;
@@ -0,0 +1 @@
1
+ export { default as MobilityLayerMixin } from './MobilityLayerMixin';
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export { default as MobilityLayerMixin } from './MobilityLayerMixin';
File without changes