mobility-toolbox-js 2.0.0-beta.39 → 2.0.0-beta.42

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/common/layers/Layer.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;;;;;;;;;;OAYG;IACH;QAT4B,GAAG;QACH,IAAI;QACF,UAAU;QACN,QAAQ;QACb,OAAO;QACP,QAAQ;QACT,YAAY;QACZ,UAAU;OA+BrC;IAvBC,iBAAuE;IAEvE,WAA0B;IAE1B,iCAAoC;IAEpC,8BAAgC;IAmBlC;;;;OAIG;IACH,qCA0HC;IAED;;;;OAIG;IACH,4BAUC;IARC,cAAc;IACd,SAAc;IAShB;;OAEG;IAEH,sBAGC;IAED;;;;;;;OAOG;IAEH,qDAJW,MAAM,GACL,QAAQ,WAAW,CAAC,CAiB/B;IAED;;OAEG;IACH,cAEC;CACF"}
1
+ {"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/common/layers/Layer.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH;IACE;;;;;;;;;;;;OAYG;IACH;QAT4B,GAAG;QACH,IAAI;QACF,UAAU;QACN,QAAQ;QACb,OAAO;QACP,QAAQ;QACT,YAAY;QACZ,UAAU;OA+BrC;IAvBC,iBAAuE;IAEvE,WAA0B;IAE1B,iCAAoC;IAEpC,8BAAgC;IAmBlC;;;;OAIG;IACH,qCAiJC;IAED;;;;OAIG;IACH,4BAUC;IARC,cAAc;IACd,SAAc;IAShB;;OAEG;IAEH,sBAGC;IAED;;;;;;;OAOG;IAEH,qDAJW,MAAM,GACL,QAAQ,WAAW,CAAC,CAiB/B;IAED;;OAEG;IACH,cAEC;CACF"}
@@ -103,14 +103,25 @@ export default class Layer extends BaseObject {
103
103
  }
104
104
  this.set('visible', newVisible);
105
105
  if (this.visible) {
106
- if (this.parent && !this.parent.visible) {
106
+ // We make the parent visible
107
+ if (this.parent) {
107
108
  this.parent.visible = true;
108
109
  }
109
- if (this.children && this.children.find((child) => child.group)) {
110
- const child = this.children.find((childd) => !!childd.group);
111
- // Make visible only radioGroup layers
110
+ // If children contains layers with group, we display one of them (the last added).
111
+ if (this.children && this.children.some((child) => !!child.group)) {
112
+ const child = this.children
113
+ .reverse()
114
+ .find((childd) => !!childd.group);
112
115
  child.visible = true;
113
116
  }
117
+ // If children doesn't contain any visible layers (not using group), we display all children (not using group).
118
+ if (this.children &&
119
+ !this.children.some((child) => !child.group && child.visible)) {
120
+ this.children.forEach((child) => {
121
+ // eslint-disable-next-line no-param-reassign
122
+ child.visible = true;
123
+ });
124
+ }
114
125
  // Warn the same group that a new layer is visible
115
126
  if (this.parent && this.group) {
116
127
  // We search for the higher parent then it will dispatch to all the tree.
@@ -125,6 +136,14 @@ export default class Layer extends BaseObject {
125
136
  }
126
137
  }
127
138
  else if (!this.visible) {
139
+ // We hide all the children
140
+ if (this.children) {
141
+ this.children.forEach((child) => {
142
+ // eslint-disable-next-line no-param-reassign
143
+ child.visible = false;
144
+ });
145
+ }
146
+ // If the parent has no more visible child we also hide it.
128
147
  if (this.parent &&
129
148
  this.parent.visible &&
130
149
  !this.parent.children.find((child) => child.visible)) {
@@ -18,17 +18,25 @@ export class UserInteractionsLayerInterface {
18
18
  */
19
19
  activateUserInteractions(): void;
20
20
  /**
21
- * Deactivaet map listeners events.
21
+ * Deactivate map listeners events.
22
22
  */
23
23
  deactivateUserInteractions(): void;
24
24
  /**
25
- * Terminate the layer unsubscribing user interactions.
25
+ * Subscribe on user:click event.
26
26
  */
27
27
  onClick(callback: any): void;
28
28
  /**
29
- * Terminate the layer unsubscribing user interactions.
29
+ * Subscribe on user:hover event.
30
30
  */
31
31
  onHover(callback: any): void;
32
+ /**
33
+ * Unsubscribe on user:click event.
34
+ */
35
+ unClick(callback: any): void;
36
+ /**
37
+ * Unsubscribe on user:hover event.
38
+ */
39
+ unHover(callback: any): void;
32
40
  }
33
41
  export default UserInteractionsLayerMixin;
34
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"UserInteractionsLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/UserInteractionsLayerMixin.js"],"names":[],"mappings":"AAQA;;GAEG;AACH;IAUE,0BAA4B;IAE5B;;;;OAIG;IACH,4BAAmB;IAEnB;;OAEG;IACH,sBAAkB;IAElB;;OAEG;IACH,iCAA6B;IAE7B;;OAEG;IACH,mCAA+B;IAE/B;;OAEG;IACH,6BAAoB;IAEpB;;OAEG;IACH,6BAAoB;CACrB;;AAED;;;;;;GAMG;AACH,gEA6KG"}
1
+ {"version":3,"file":"UserInteractionsLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/UserInteractionsLayerMixin.js"],"names":[],"mappings":"AAQA;;GAEG;AACH;IAUE,0BAA4B;IAE5B;;;;OAIG;IACH,4BAAmB;IAEnB;;OAEG;IACH,sBAAkB;IAElB;;OAEG;IACH,iCAA6B;IAE7B;;OAEG;IACH,mCAA+B;IAE/B;;OAEG;IACH,6BAAoB;IAEpB;;OAEG;IACH,6BAAoB;IAEpB;;OAEG;IACH,6BAAoB;IAEpB;;OAEG;IACH,6BAAoB;CACrB;;AAED;;;;;;GAMG;AACH,gEAkNG"}
@@ -34,17 +34,25 @@ export class UserInteractionsLayerInterface {
34
34
  */
35
35
  activateUserInteractions() { }
36
36
  /**
37
- * Deactivaet map listeners events.
37
+ * Deactivate map listeners events.
38
38
  */
39
39
  deactivateUserInteractions() { }
40
40
  /**
41
- * Terminate the layer unsubscribing user interactions.
41
+ * Subscribe on user:click event.
42
42
  */
43
43
  onClick(callback) { }
44
44
  /**
45
- * Terminate the layer unsubscribing user interactions.
45
+ * Subscribe on user:hover event.
46
46
  */
47
47
  onHover(callback) { }
48
+ /**
49
+ * Unsubscribe on user:click event.
50
+ */
51
+ unClick(callback) { }
52
+ /**
53
+ * Unsubscribe on user:hover event.
54
+ */
55
+ unHover(callback) { }
48
56
  }
49
57
  /**
50
58
  * Mixin for UserInteractionsLayerInterface. It provide onClick and onHover functions.
@@ -142,6 +150,39 @@ const UserInteractionsLayerMixin = (Base) => class extends Base {
142
150
  this.listenEvents();
143
151
  }
144
152
  }
153
+ /**
154
+ * Unlistens to click events on the layer.
155
+ * @param {function} callback Callback function, called with the clicked
156
+ * features,
157
+ * the layer instance and the click event.
158
+ */
159
+ unClick(callback) {
160
+ const index = this.userClickCallbacks.indexOf(callback);
161
+ if (index !== -1) {
162
+ return;
163
+ }
164
+ this.userClickCallbacks = this.userClickCallbacks.slice(index, 1);
165
+ if (this.map) {
166
+ // If the layer is already attached to the map we reload the events
167
+ this.listenEvents();
168
+ }
169
+ }
170
+ /**
171
+ * Unlistens to hover events on the layer.
172
+ * @param {function} callback Callback function, called with the clicked
173
+ * features, the layer instance and the click event.
174
+ */
175
+ unHover(callback) {
176
+ const index = this.userHoverCallbacks.indexOf(callback);
177
+ if (index !== -1) {
178
+ return;
179
+ }
180
+ this.userHoverCallbacks = this.userHoverCallbacks.slice(index, 1);
181
+ if (this.map) {
182
+ // If the layer is already attached to the map we reload the events
183
+ this.listenEvents();
184
+ }
185
+ }
145
186
  /**
146
187
  * Function triggered when the user click the map.
147
188
  * @private
package/mbt.js CHANGED
@@ -47845,13 +47845,18 @@ uniform ${i3} ${o3} u_${a3};
47845
47845
  }
47846
47846
  this.set("visible", newVisible);
47847
47847
  if (this.visible) {
47848
- if (this.parent && !this.parent.visible) {
47848
+ if (this.parent) {
47849
47849
  this.parent.visible = true;
47850
47850
  }
47851
- if (this.children && this.children.find((child) => child.group)) {
47852
- const child = this.children.find((childd) => !!childd.group);
47851
+ if (this.children && this.children.some((child) => !!child.group)) {
47852
+ const child = this.children.reverse().find((childd) => !!childd.group);
47853
47853
  child.visible = true;
47854
47854
  }
47855
+ if (this.children && !this.children.some((child) => !child.group && child.visible)) {
47856
+ this.children.forEach((child) => {
47857
+ child.visible = true;
47858
+ });
47859
+ }
47855
47860
  if (this.parent && this.group) {
47856
47861
  let higherParent = this.parent;
47857
47862
  while (higherParent.parent) {
@@ -47863,6 +47868,11 @@ uniform ${i3} ${o3} u_${a3};
47863
47868
  });
47864
47869
  }
47865
47870
  } else if (!this.visible) {
47871
+ if (this.children) {
47872
+ this.children.forEach((child) => {
47873
+ child.visible = false;
47874
+ });
47875
+ }
47866
47876
  if (this.parent && this.parent.visible && !this.parent.children.find((child) => child.visible)) {
47867
47877
  this.parent.visible = false;
47868
47878
  }
@@ -48002,6 +48012,26 @@ uniform ${i3} ${o3} u_${a3};
48002
48012
  this.listenEvents();
48003
48013
  }
48004
48014
  }
48015
+ unClick(callback) {
48016
+ const index = this.userClickCallbacks.indexOf(callback);
48017
+ if (index !== -1) {
48018
+ return;
48019
+ }
48020
+ this.userClickCallbacks = this.userClickCallbacks.slice(index, 1);
48021
+ if (this.map) {
48022
+ this.listenEvents();
48023
+ }
48024
+ }
48025
+ unHover(callback) {
48026
+ const index = this.userHoverCallbacks.indexOf(callback);
48027
+ if (index !== -1) {
48028
+ return;
48029
+ }
48030
+ this.userHoverCallbacks = this.userHoverCallbacks.slice(index, 1);
48031
+ if (this.map) {
48032
+ this.listenEvents();
48033
+ }
48034
+ }
48005
48035
  onUserClickCallback(evt) {
48006
48036
  const coordinate = evt.coordinate || fromLonLat(evt.lngLat.toArray());
48007
48037
  const emptyFeatureInfo = {
@@ -49601,8 +49631,8 @@ uniform ${i3} ${o3} u_${a3};
49601
49631
  attachToMap(map) {
49602
49632
  super.attachToMap(map);
49603
49633
  if (this.map) {
49604
- this.olListenersKeys.push(this.map.on(["moveend", "change:target"], (evt) => {
49605
- const view = this.map.getView();
49634
+ this.olListenersKeys.push(...this.map.on(["moveend", "change:target"], (evt) => {
49635
+ const view = evt.map.getView();
49606
49636
  if (view.getAnimating() || view.getInteracting()) {
49607
49637
  return;
49608
49638
  }
@@ -49628,6 +49658,9 @@ uniform ${i3} ${o3} u_${a3};
49628
49658
  return false;
49629
49659
  }
49630
49660
  renderTrajectories(noInterpolate) {
49661
+ if (!this.map) {
49662
+ return;
49663
+ }
49631
49664
  const view = this.map.getView();
49632
49665
  super.renderTrajectories({
49633
49666
  size: this.map.getSize(),