mobility-toolbox-js 3.0.0-beta.27 → 3.0.0-beta.29

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
@@ -52204,14 +52204,11 @@ uniform ${i3} ${a3} u_${s3};
52204
52204
  );
52205
52205
  this.setProperties(options.properties);
52206
52206
  }
52207
- this.olEventsKeys?.push(
52208
- // Update parent property
52209
- this.on("propertychange", (evt) => {
52210
- if (evt.key === "children") {
52211
- this.onChildrenChange(evt.oldValue);
52212
- }
52213
- })
52214
- );
52207
+ this.on("propertychange", (evt) => {
52208
+ if (evt.key === "children") {
52209
+ this.onChildrenChange(evt.oldValue);
52210
+ }
52211
+ });
52215
52212
  this.options = options;
52216
52213
  this.set("children", options.children || []);
52217
52214
  }
@@ -52231,6 +52228,7 @@ uniform ${i3} ${a3} u_${s3};
52231
52228
  * Terminate what was initialized in init function. Remove layer, events...
52232
52229
  */
52233
52230
  detachFromMap() {
52231
+ unByKey(this.olEventsKeys);
52234
52232
  (this.get("children") || []).forEach((child) => {
52235
52233
  this.map.removeLayer(child);
52236
52234
  });
@@ -52437,7 +52435,9 @@ uniform ${i3} ${a3} u_${s3};
52437
52435
  ...options.mapLibreOptions || {}
52438
52436
  }
52439
52437
  };
52440
- if (!newOptions.mapLibreOptions.style && newOptions.apiKey && newOptions.style && typeof newOptions.style === "string") {
52438
+ if (!newOptions.mapLibreOptions.style && newOptions.url?.includes("style.json")) {
52439
+ newOptions.mapLibreOptions.style = newOptions.url;
52440
+ } else if (!newOptions.mapLibreOptions.style && newOptions.apiKey && newOptions.style && typeof newOptions.style === "string") {
52441
52441
  newOptions.mapLibreOptions.style = buildStyleUrl(
52442
52442
  newOptions.url,
52443
52443
  newOptions.style,
@@ -52771,6 +52771,16 @@ uniform ${i3} ${a3} u_${s3};
52771
52771
  this.detachFromMap();
52772
52772
  this.attachToMap(map);
52773
52773
  }
52774
+ }),
52775
+ // When the style changes we wait that it is loaded to relaunch the onLoad
52776
+ this.maplibreLayer.on("propertychange", (evt) => {
52777
+ if (evt.key === "style") {
52778
+ evt.target.maplibreMap.once("styledata", () => {
52779
+ evt.target.maplibreMap.once("idle", () => {
52780
+ this.onLoad();
52781
+ });
52782
+ });
52783
+ }
52774
52784
  })
52775
52785
  );
52776
52786
  }