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.
@@ -53,8 +53,13 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
53
53
  * @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
54
54
  */
55
55
  constructor(options) {
56
+ var _a;
56
57
  const newOptions = Object.assign(Object.assign({ apiKeyName: 'key', style: 'travic_v2', url: 'https://maps.geops.io' }, (options || {})), { mapLibreOptions: Object.assign({}, (options.mapLibreOptions || {})) });
57
58
  if (!newOptions.mapLibreOptions.style &&
59
+ ((_a = newOptions.url) === null || _a === void 0 ? void 0 : _a.includes('style.json'))) {
60
+ newOptions.mapLibreOptions.style = newOptions.url;
61
+ }
62
+ else if (!newOptions.mapLibreOptions.style &&
58
63
  newOptions.apiKey &&
59
64
  newOptions.style &&
60
65
  typeof newOptions.style === 'string') {
@@ -185,6 +185,16 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
185
185
  this.detachFromMap();
186
186
  this.attachToMap(map);
187
187
  }
188
+ }),
189
+ // When the style changes we wait that it is loaded to relaunch the onLoad
190
+ this.maplibreLayer.on('propertychange', (evt) => {
191
+ if (evt.key === 'style') {
192
+ evt.target.maplibreMap.once('styledata', () => {
193
+ evt.target.maplibreMap.once('idle', () => {
194
+ this.onLoad();
195
+ });
196
+ });
197
+ }
188
198
  }));
189
199
  }
190
200
  /**
@@ -117,7 +117,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
117
117
  hasProperties: () => boolean;
118
118
  notify: (key: string, oldValue: any) => void;
119
119
  addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
120
- removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
120
+ removeChangeListener: (key: string, listener: import("ol/events" /** @deprecated */).Listener) => void;
121
121
  set: (key: string, value: any, silent?: boolean | undefined) => void;
122
122
  setProperties: (values: {
123
123
  [x: string]: any;
@@ -1,6 +1,7 @@
1
1
  // eslint-disable-next-line max-classes-per-file
2
2
  import debounce from 'lodash.debounce';
3
3
  import { getUid } from 'ol';
4
+ import { unByKey } from 'ol/Observable';
4
5
  import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
5
6
  let deprecated = () => { };
6
7
  if (typeof window !== 'undefined' &&
@@ -16,7 +17,6 @@ if (typeof window !== 'undefined' &&
16
17
  function PropertiesLayerMixin(Base) {
17
18
  return class PropertiesLayer extends Base {
18
19
  constructor(...args) {
19
- var _a;
20
20
  const options = args[0];
21
21
  super(options);
22
22
  this.olEventsKeys = [];
@@ -25,13 +25,12 @@ function PropertiesLayerMixin(Base) {
25
25
  deprecated("Deprecated. Don't use properties options. Pass the values directly in options object.");
26
26
  this.setProperties(options.properties);
27
27
  }
28
- (_a = this.olEventsKeys) === null || _a === void 0 ? void 0 : _a.push(
29
28
  // Update parent property
30
29
  this.on('propertychange', (evt) => {
31
30
  if (evt.key === 'children') {
32
31
  this.onChildrenChange(evt.oldValue);
33
32
  }
34
- }));
33
+ });
35
34
  this.options = options;
36
35
  this.set('children', options.children || []); // Trigger the on children change event
37
36
  }
@@ -51,6 +50,7 @@ function PropertiesLayerMixin(Base) {
51
50
  * Terminate what was initialized in init function. Remove layer, events...
52
51
  */
53
52
  detachFromMap() {
53
+ unByKey(this.olEventsKeys);
54
54
  (this.get('children') || []).forEach((child) => {
55
55
  this.map.removeLayer(child);
56
56
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "3.0.0-beta.27",
5
+ "version": "3.0.0-beta.29",
6
6
  "homepage": "https://mobility-toolbox-js.geops.io/",
7
7
  "exports": {
8
8
  ".": "./index.js",