mobility-toolbox-js 3.0.0-beta.1 → 3.0.0-beta.3

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.
@@ -8,7 +8,7 @@ const getLayersAsFlatArray = (layersOrLayer) => {
8
8
  let flatLayers = [];
9
9
  layers.forEach((layer) => {
10
10
  flatLayers.push(layer);
11
- const { children } = layer;
11
+ const children = layer.children || layer.get('children') || {};
12
12
  flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
13
13
  });
14
14
  return flatLayers;
package/mbt.js CHANGED
@@ -20225,7 +20225,7 @@ uniform ${i3} ${s3} u_${a3};
20225
20225
  let flatLayers = [];
20226
20226
  layers.forEach((layer) => {
20227
20227
  flatLayers.push(layer);
20228
- const { children } = layer;
20228
+ const children = layer.children || layer.get("children") || {};
20229
20229
  flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
20230
20230
  });
20231
20231
  return flatLayers;
@@ -45730,7 +45730,7 @@ uniform ${i3} ${s3} u_${a3};
45730
45730
  container.style.width = "100%";
45731
45731
  container.style.height = "100%";
45732
45732
  this.mbMap = this.createMap({
45733
- style: this.getStyle() || { version: "8", sources: {}, layers: [] },
45733
+ style: this.getStyle(),
45734
45734
  container,
45735
45735
  ...this.options?.mapOptions || {}
45736
45736
  });
@@ -46101,11 +46101,11 @@ uniform ${i3} ${s3} u_${a3};
46101
46101
  maplibreMap.once("load", this.onLoad);
46102
46102
  }
46103
46103
  this.olListenersKeys.push(
46104
+ // @ts-expect-error 'load' is a custom event form mobility-toolbox-js
46105
+ this.maplibreLayer.on("load", this.onLoad.bind(this)),
46104
46106
  this.on("change:visible", (evt) => {
46105
46107
  this.applyLayoutVisibility(evt);
46106
46108
  }),
46107
- // @ts-expect-error 'load' is a custom event form mobility-toolbox-js
46108
- this.maplibreLayer.on("load", this.onLoad),
46109
46109
  this.on("propertychange", (evt) => {
46110
46110
  if (/(sources|layers|layersFilter|maplibreLayer|beforeId|)/.test(evt.key)) {
46111
46111
  this.detachFromMap();
@@ -46128,13 +46128,12 @@ uniform ${i3} ${s3} u_${a3};
46128
46128
  }
46129
46129
  /** @private */
46130
46130
  addSources() {
46131
- if (!this.maplibreLayer?.maplibreMap || !Array.isArray(this.sources)) {
46131
+ if (!this.maplibreLayer?.maplibreMap || !this.sources) {
46132
46132
  return;
46133
46133
  }
46134
46134
  const { maplibreMap } = this.maplibreLayer;
46135
46135
  if (maplibreMap) {
46136
- this.sources.forEach((source) => {
46137
- const { id } = source;
46136
+ Object.entries(this.sources).forEach(([id, source]) => {
46138
46137
  if (!maplibreMap.getSource(id)) {
46139
46138
  maplibreMap.addSource(id, source);
46140
46139
  }
@@ -46143,13 +46142,12 @@ uniform ${i3} ${s3} u_${a3};
46143
46142
  }
46144
46143
  /** @private */
46145
46144
  removeSources() {
46146
- if (!this.maplibreLayer?.maplibreMap || !Array.isArray(this.layers)) {
46145
+ if (!this.maplibreLayer?.maplibreMap || !this.sources) {
46147
46146
  return;
46148
46147
  }
46149
46148
  const { maplibreMap } = this.maplibreLayer;
46150
46149
  if (maplibreMap) {
46151
- this.sources.forEach((source) => {
46152
- const { id } = source;
46150
+ Object.keys(this.sources).forEach((id) => {
46153
46151
  if (maplibreMap.getSource(id)) {
46154
46152
  maplibreMap.removeSource(id);
46155
46153
  }