mobility-toolbox-js 3.0.1-beta.8 → 3.0.1-beta.9

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.
package/mbt.js CHANGED
@@ -47477,6 +47477,10 @@ uniform ${i3} ${a3} u_${s3};
47477
47477
  );
47478
47478
  }
47479
47479
  }
47480
+ cleanVectorLayer() {
47481
+ this.vectorLayer?.getSource()?.clear(true);
47482
+ this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
47483
+ }
47480
47484
  /**
47481
47485
  * Create a copy of the RealtimeLayer.
47482
47486
  *
@@ -47574,23 +47578,28 @@ uniform ${i3} ${a3} u_${s3};
47574
47578
  * Highlight the trajectory of journey.
47575
47579
  */
47576
47580
  async highlightTrajectory(id) {
47577
- this.vectorLayer?.getSource()?.clear(true);
47578
- this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
47579
47581
  if (!id) {
47582
+ this.cleanVectorLayer();
47580
47583
  return;
47581
47584
  }
47582
47585
  const features = await this.getFullTrajectory(id);
47583
47586
  if (!features?.length) {
47587
+ this.cleanVectorLayer();
47584
47588
  return;
47585
47589
  }
47586
47590
  if (features.length) {
47587
47591
  this.vectorLayer?.getSource()?.addFeatures(features);
47588
47592
  }
47593
+ if (this.vectorLayer.getMapInternal() && this.vectorLayer.getMapInternal() !== this.getMapInternal()) {
47594
+ this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
47595
+ }
47589
47596
  const zIndex = this.getZIndex();
47590
47597
  if (zIndex !== void 0) {
47591
47598
  this.vectorLayer.setZIndex(zIndex - 1);
47592
- this.getMapInternal()?.addLayer(this.vectorLayer);
47593
- } else {
47599
+ if (!this.vectorLayer.getMapInternal()) {
47600
+ this.getMapInternal()?.addLayer(this.vectorLayer);
47601
+ }
47602
+ } else if (!this.vectorLayer.getMapInternal()) {
47594
47603
  const index = this.getMapInternal()?.getLayers().getArray().indexOf(this) || 0;
47595
47604
  if (index) {
47596
47605
  this.getMapInternal()?.getLayers().insertAt(index, this.vectorLayer);