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

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
@@ -46086,8 +46086,7 @@ uniform ${i3} ${s3} u_${a3};
46086
46086
  if (!this.map || !this.maplibreLayer) {
46087
46087
  return;
46088
46088
  }
46089
- const { maplibreMap } = this.maplibreLayer;
46090
- if (!maplibreMap) {
46089
+ if (!this.map.getTargetElement()) {
46091
46090
  this.olListenersKeys.push(
46092
46091
  this.map.on("change:target", () => {
46093
46092
  this.attachToMap(map2);
@@ -46095,10 +46094,13 @@ uniform ${i3} ${s3} u_${a3};
46095
46094
  );
46096
46095
  return;
46097
46096
  }
46098
- if (maplibreMap.loaded()) {
46099
- this.onLoad();
46100
- } else {
46101
- maplibreMap.once("load", this.onLoad);
46097
+ const { maplibreMap } = this.maplibreLayer;
46098
+ if (maplibreMap) {
46099
+ if (maplibreMap.loaded()) {
46100
+ this.onLoad();
46101
+ } else {
46102
+ maplibreMap.once("load", this.onLoad);
46103
+ }
46102
46104
  }
46103
46105
  this.olListenersKeys.push(
46104
46106
  // @ts-expect-error 'load' is a custom event form mobility-toolbox-js
@@ -46128,13 +46130,12 @@ uniform ${i3} ${s3} u_${a3};
46128
46130
  }
46129
46131
  /** @private */
46130
46132
  addSources() {
46131
- if (!this.maplibreLayer?.maplibreMap || !Array.isArray(this.sources)) {
46133
+ if (!this.maplibreLayer?.maplibreMap || !this.sources) {
46132
46134
  return;
46133
46135
  }
46134
46136
  const { maplibreMap } = this.maplibreLayer;
46135
46137
  if (maplibreMap) {
46136
- this.sources.forEach((source) => {
46137
- const { id } = source;
46138
+ Object.entries(this.sources).forEach(([id, source]) => {
46138
46139
  if (!maplibreMap.getSource(id)) {
46139
46140
  maplibreMap.addSource(id, source);
46140
46141
  }
@@ -46143,13 +46144,12 @@ uniform ${i3} ${s3} u_${a3};
46143
46144
  }
46144
46145
  /** @private */
46145
46146
  removeSources() {
46146
- if (!this.maplibreLayer?.maplibreMap || !Array.isArray(this.layers)) {
46147
+ if (!this.maplibreLayer?.maplibreMap || !this.sources) {
46147
46148
  return;
46148
46149
  }
46149
46150
  const { maplibreMap } = this.maplibreLayer;
46150
46151
  if (maplibreMap) {
46151
- this.sources.forEach((source) => {
46152
- const { id } = source;
46152
+ Object.keys(this.sources).forEach((id) => {
46153
46153
  if (maplibreMap.getSource(id)) {
46154
46154
  maplibreMap.removeSource(id);
46155
46155
  }