mobility-toolbox-js 3.0.0-beta.37 → 3.0.0-beta.38

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
@@ -17993,7 +17993,6 @@ uniform ${i3} ${a3} u_${s3};
17993
17993
  Layer: () => Layer_default4,
17994
17994
  MaplibreLayer: () => MaplibreLayer_default,
17995
17995
  MaplibreStyleLayer: () => MaplibreStyleLayer_default,
17996
- MobilityLayerMixin: () => MobilityLayerMixin_default,
17997
17996
  RealtimeAPI: () => RealtimeAPI_default,
17998
17997
  RealtimeLayer: () => RealtimeLayer_default,
17999
17998
  RealtimeModes: () => RealtimeModes,
@@ -25014,7 +25013,6 @@ uniform ${i3} ${a3} u_${s3};
25014
25013
  // src/common/utils/getVehiclePosition.ts
25015
25014
  var getVehiclePosition = (now, trajectory, noInterpolate) => {
25016
25015
  const {
25017
- // @ts-expect-error coordinate is added by the RealtimeLayer
25018
25016
  coordinate,
25019
25017
  // @ts-expect-error olGeometry is added by the RealtimeLayer
25020
25018
  olGeometry,
@@ -45322,7 +45320,7 @@ uniform ${i3} ${a3} u_${s3};
45322
45320
  // src/ol/layers/MaplibreLayer.ts
45323
45321
  var import_lodash2 = __toESM(require_lodash());
45324
45322
 
45325
- // src/ol/mixins/PropertiesLayerMixin.ts
45323
+ // src/ol/utils/defineDeprecatedProperties.ts
45326
45324
  var import_lodash = __toESM(require_lodash());
45327
45325
  var deprecated = () => {
45328
45326
  };
@@ -45331,213 +45329,207 @@ uniform ${i3} ${a3} u_${s3};
45331
45329
  console.warn(message);
45332
45330
  }, 1e3);
45333
45331
  }
45334
- function PropertiesLayerMixin(Base) {
45335
- return class PropertiesLayer extends Base {
45336
- constructor(...args) {
45337
- const options = args[0];
45338
- super(options);
45339
- this.olEventsKeys = [];
45340
- this.options = {};
45341
- if (options.properties) {
45342
- deprecated(
45343
- "Deprecated. Don't use properties options. Pass the values directly in options object."
45344
- );
45345
- this.setProperties(options.properties);
45346
- }
45347
- this.on("propertychange", (evt) => {
45348
- if (evt.key === "children") {
45349
- this.onChildrenChange(evt.oldValue);
45350
- }
45351
- });
45352
- this.options = options;
45353
- this.set("children", options.children || []);
45354
- }
45355
- /**
45356
- * Initialize the layer with the map passed in parameters.
45357
- *
45358
- * @param {ol/Map~Map} map A map.
45359
- */
45360
- attachToMap(map) {
45361
- (super.attachToMap || (() => {
45362
- }))(map);
45363
- (this.get("children") || []).forEach((child) => {
45364
- map.addLayer(child);
45365
- });
45366
- }
45367
- /**
45368
- * Terminate what was initialized in init function. Remove layer, events...
45369
- */
45370
- detachFromMap() {
45371
- unByKey(this.olEventsKeys);
45372
- (this.get("children") || []).forEach((child) => {
45373
- this.map.removeLayer(child);
45374
- });
45375
- (super.detachFromMap || (() => {
45376
- }))();
45377
- }
45378
- /**
45379
- * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
45380
- * @deprecated
45381
- */
45382
- flat() {
45383
- deprecated(
45384
- "Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."
45385
- );
45386
- return getLayersAsFlatArray_default(this);
45387
- }
45388
- onChildrenChange(oldValue) {
45389
- (oldValue || []).forEach((child) => {
45390
- child.set("parent", void 0);
45391
- });
45392
- (this.get("children") || []).forEach((child) => {
45393
- child.set("parent", this);
45394
- });
45332
+ var onChildrenChange = (layer, oldValue) => {
45333
+ (oldValue || []).forEach((child) => {
45334
+ child.set("parent", void 0);
45335
+ });
45336
+ (layer.get("children") || []).forEach((child) => {
45337
+ child.set("parent", void 0);
45338
+ });
45339
+ };
45340
+ var defineDeprecatedProperties = (obj, options) => {
45341
+ if (options.properties) {
45342
+ deprecated(
45343
+ "Deprecated. Don't use properties options. Pass the values directly in options object."
45344
+ );
45345
+ obj.setProperties(options.properties);
45346
+ }
45347
+ obj.on("propertychange", (evt) => {
45348
+ if (evt.key === "children") {
45349
+ onChildrenChange(evt.target, evt.oldValue);
45395
45350
  }
45396
- // @ts-expect-error - this is a mixin
45397
- setMapInternal(map) {
45351
+ if (evt.key === "map") {
45352
+ const map = evt.target.get(evt.key);
45398
45353
  if (map) {
45399
- super.setMapInternal(map);
45400
- this.attachToMap(map);
45401
- } else {
45402
- this.detachFromMap();
45403
- super.setMapInternal(map);
45354
+ (evt.target.get("children") || []).forEach((child) => {
45355
+ map.addLayer(child);
45356
+ });
45357
+ } else if (evt.oldValue) {
45358
+ (evt.target.get("children") || []).forEach((child) => {
45359
+ evt.oldValue.removeLayer(child);
45360
+ });
45404
45361
  }
45405
45362
  }
45406
- /** @deprecated */
45407
- get children() {
45408
- deprecated(
45409
- "Layer.children is deprecated. Use the Layer.get('children') method instead."
45410
- );
45411
- return this.get("children") || [];
45412
- }
45413
- /** @deprecated */
45414
- set children(newValue) {
45415
- deprecated(
45416
- "Layer.children is deprecated. Use the Layer.set('children', children) method instead."
45417
- );
45418
- this.set("children", newValue || []);
45419
- }
45420
- /** @deprecated */
45421
- get copyrights() {
45422
- deprecated(
45423
- "Layer.copyrights is deprecated. Get the attributions from the source object"
45424
- );
45425
- return this.get("copyrights");
45426
- }
45427
- /** @deprecated */
45428
- set copyrights(newCopyrights) {
45429
- deprecated(
45430
- "Layer.copyrights is deprecated. Set the attributions to the source object."
45431
- );
45432
- const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
45433
- this.set("copyrights", arrValue || []);
45434
- }
45435
- /** @deprecated */
45436
- get disabled() {
45437
- deprecated(
45438
- "Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."
45439
- );
45440
- return this.get("disabled");
45441
- }
45442
- /** @deprecated */
45443
- set disabled(newValue) {
45444
- deprecated(
45445
- "Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."
45446
- );
45447
- this.set("disabled", newValue);
45448
- }
45449
- /** @deprecated */
45450
- get group() {
45451
- deprecated(
45452
- "Layer.group is deprecated. Use the Layer.get('group') method instead."
45453
- );
45454
- return this.get("group");
45455
- }
45456
- /** @deprecated */
45457
- get hitTolerance() {
45458
- deprecated(
45459
- "Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."
45460
- );
45461
- return this.get("hitTolerance") || 5;
45462
- }
45463
- /** @deprecated */
45464
- set hitTolerance(newValue) {
45465
- deprecated(
45466
- "Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."
45467
- );
45468
- this.set("hitTolerance", newValue);
45469
- }
45470
- get key() {
45471
- return this.get("key") || this.get("name");
45472
- }
45473
- get map() {
45474
- return this.getMapInternal();
45475
- }
45476
- /** @deprecated */
45477
- get name() {
45478
- deprecated(
45479
- "Layer.name is deprecated. Use the Layer.get('name') method instead."
45480
- );
45481
- return this.get("name");
45482
- }
45483
- /** @deprecated */
45484
- get olLayer() {
45485
- deprecated(
45486
- "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."
45487
- );
45488
- return this;
45489
- }
45490
- // eslint-disable-next-line class-methods-use-this
45491
- set olLayer(newValue) {
45492
- deprecated(
45493
- "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect."
45494
- );
45495
- }
45496
- /** @deprecated */
45497
- // get olListenersKeys(): EventsKey[] {
45498
- // return this.olEventsKeys;
45499
- // }
45500
- /** @deprecated */
45501
- get parent() {
45502
- deprecated(
45503
- "Layer.parent is deprecated. Use the Layer.get('parent') method instead."
45504
- );
45505
- return this.get("parent");
45506
- }
45507
- /** @deprecated */
45508
- set parent(newValue) {
45509
- deprecated(
45510
- "Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."
45511
- );
45512
- this.set("parent", newValue);
45513
- }
45514
- /** @deprecated */
45515
- get visible() {
45516
- deprecated(
45517
- "Layer.visible is deprecated. Use the Layer.getVisible() method instead."
45518
- );
45519
- return this.getVisible();
45520
- }
45521
- /** @deprecated */
45522
- set visible(newValue) {
45523
- deprecated(
45524
- "Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."
45525
- );
45526
- this.setVisible(newValue);
45363
+ });
45364
+ obj.set("options", options);
45365
+ obj.set("children", options.children || []);
45366
+ Object.defineProperties(obj, {
45367
+ children: {
45368
+ /** @deprecated */
45369
+ get: () => {
45370
+ deprecated(
45371
+ "Layer.children is deprecated. Use the Layer.get('children') method instead."
45372
+ );
45373
+ return obj.get("children") || [];
45374
+ },
45375
+ /** @deprecated */
45376
+ set: (newValue) => {
45377
+ deprecated(
45378
+ "Layer.children is deprecated. Use the Layer.set('children', children) method instead."
45379
+ );
45380
+ obj.set("children", newValue || []);
45381
+ }
45382
+ },
45383
+ copyrights: {
45384
+ /** @deprecated */
45385
+ get: () => {
45386
+ deprecated(
45387
+ "Layer.copyrights is deprecated. Get the attributions from the source object"
45388
+ );
45389
+ return obj.get("copyrights");
45390
+ },
45391
+ /** @deprecated */
45392
+ set: (newCopyrights) => {
45393
+ deprecated(
45394
+ "Layer.copyrights is deprecated. Set the attributions to the source object."
45395
+ );
45396
+ const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
45397
+ obj.set("copyrights", arrValue || []);
45398
+ }
45399
+ },
45400
+ disabled: {
45401
+ /** @deprecated */
45402
+ get() {
45403
+ deprecated(
45404
+ "Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."
45405
+ );
45406
+ return obj.get("disabled");
45407
+ },
45408
+ /** @deprecated */
45409
+ set(newValue) {
45410
+ deprecated(
45411
+ "Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."
45412
+ );
45413
+ obj.set("disabled", newValue);
45414
+ }
45415
+ },
45416
+ group: {
45417
+ /** @deprecated */
45418
+ get() {
45419
+ deprecated(
45420
+ "Layer.group is deprecated. Use the Layer.get('group') method instead."
45421
+ );
45422
+ return obj.get("group");
45423
+ }
45424
+ },
45425
+ hitTolerance: {
45426
+ /** @deprecated */
45427
+ get() {
45428
+ deprecated(
45429
+ "Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."
45430
+ );
45431
+ return obj.get("hitTolerance") || 5;
45432
+ },
45433
+ /** @deprecated */
45434
+ set(newValue) {
45435
+ deprecated(
45436
+ "Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."
45437
+ );
45438
+ obj.set("hitTolerance", newValue);
45439
+ }
45440
+ },
45441
+ key: {
45442
+ /** @deprecated */
45443
+ get() {
45444
+ deprecated(
45445
+ 'Layer.key is deprecated. Use the Layer.get("key") method instead.'
45446
+ );
45447
+ return obj.get("key") || obj.get("name");
45448
+ }
45449
+ },
45450
+ map: {
45451
+ /** @deprecated */
45452
+ get() {
45453
+ deprecated(
45454
+ 'Layer.map is deprecated. Use the Layer.get("map") method instead.'
45455
+ );
45456
+ return obj.getMapInternal();
45457
+ }
45458
+ },
45459
+ name: {
45460
+ /** @deprecated */
45461
+ get() {
45462
+ deprecated(
45463
+ "Layer.name is deprecated. Use the Layer.get('name') method instead."
45464
+ );
45465
+ return obj.get("name");
45466
+ }
45467
+ },
45468
+ olLayer: {
45469
+ /** @deprecated */
45470
+ get() {
45471
+ deprecated(
45472
+ "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."
45473
+ );
45474
+ return obj;
45475
+ },
45476
+ /** @deprecated */
45477
+ set() {
45478
+ deprecated(
45479
+ "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect."
45480
+ );
45481
+ }
45482
+ },
45483
+ options: {
45484
+ /** @deprecated */
45485
+ get() {
45486
+ deprecated(
45487
+ 'Layer.options is deprecated. Use the Layer.get("options") method instead.'
45488
+ );
45489
+ return obj.get("options");
45490
+ },
45491
+ set(newValue) {
45492
+ deprecated(
45493
+ 'Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'
45494
+ );
45495
+ return obj.set("options", newValue);
45496
+ }
45497
+ },
45498
+ parent: {
45499
+ /** @deprecated */
45500
+ get() {
45501
+ deprecated(
45502
+ "Layer.parent is deprecated. Use the Layer.get('parent') method instead."
45503
+ );
45504
+ return obj.get("parent");
45505
+ },
45506
+ /** @deprecated */
45507
+ set(newValue) {
45508
+ deprecated(
45509
+ "Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."
45510
+ );
45511
+ obj.set("parent", newValue);
45512
+ }
45513
+ },
45514
+ visible: {
45515
+ /** @deprecated */
45516
+ get() {
45517
+ deprecated(
45518
+ "Layer.visible is deprecated. Use the Layer.getVisible() method instead."
45519
+ );
45520
+ return obj.getVisible();
45521
+ },
45522
+ /** @deprecated */
45523
+ set(newValue) {
45524
+ deprecated(
45525
+ "Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."
45526
+ );
45527
+ obj.setVisible(newValue);
45528
+ }
45527
45529
  }
45528
- };
45529
- }
45530
- var PropertiesLayerMixin_default = PropertiesLayerMixin;
45531
-
45532
- // src/ol/mixins/MobilityLayerMixin.ts
45533
- function MobilityLayerMixin(Base) {
45534
- return class MobilityLayer extends PropertiesLayerMixin_default(Base) {
45535
- // constructor(options: MobilityLayerOptions = {}) {
45536
- // super(options);
45537
- // }
45538
- };
45539
- }
45540
- var MobilityLayerMixin_default = MobilityLayerMixin;
45530
+ });
45531
+ };
45532
+ var defineDeprecatedProperties_default = defineDeprecatedProperties;
45541
45533
 
45542
45534
  // src/ol/layers/MaplibreLayer.ts
45543
45535
  var buildStyleUrl = (url, style, apiKey, apiKeyName) => {
@@ -45552,7 +45544,7 @@ uniform ${i3} ${a3} u_${s3};
45552
45544
  console.warn(message);
45553
45545
  }, 1e3);
45554
45546
  }
45555
- var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(MapLibreLayer) {
45547
+ var MaplibreLayer = class _MaplibreLayer extends MapLibreLayer {
45556
45548
  /**
45557
45549
  * Constructor.
45558
45550
  *
@@ -45584,14 +45576,14 @@ uniform ${i3} ${a3} u_${s3};
45584
45576
  );
45585
45577
  }
45586
45578
  super(newOptions);
45579
+ this.olEventsKeys = [];
45580
+ defineDeprecatedProperties_default(this, options);
45587
45581
  this.set("options", options);
45588
45582
  }
45589
45583
  /**
45590
45584
  * Initialize the layer and listen to feature clicks.
45591
- * @param {ol/Map~Map} map An OpenLayers map.
45592
45585
  */
45593
- attachToMap(map) {
45594
- super.attachToMap(map);
45586
+ attachToMap() {
45595
45587
  const updateMaplibreMapDebounced = (0, import_lodash2.default)(
45596
45588
  this.updateMaplibreMap.bind(this),
45597
45589
  150
@@ -45605,14 +45597,6 @@ uniform ${i3} ${a3} u_${s3};
45605
45597
  })
45606
45598
  );
45607
45599
  }
45608
- // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
45609
- // return this.get('queryRenderedFeaturesOptions');
45610
- // }
45611
- // set queryRenderedFeaturesOptions(
45612
- // newValue: maplibregl.QueryRenderedFeaturesOptions,
45613
- // ) {
45614
- // this.set('queryRenderedFeaturesOptions', newValue);
45615
- // }
45616
45600
  /**
45617
45601
  * Create a copy of the MaplibreLayer.
45618
45602
  *
@@ -45622,10 +45606,13 @@ uniform ${i3} ${a3} u_${s3};
45622
45606
  */
45623
45607
  clone(newOptions) {
45624
45608
  return new _MaplibreLayer({
45625
- ...this.options || {},
45609
+ ...this.get("options") || {},
45626
45610
  ...newOptions || {}
45627
45611
  });
45628
45612
  }
45613
+ detachFromMap() {
45614
+ unByKey(this.olEventsKeys);
45615
+ }
45629
45616
  getStyle() {
45630
45617
  if (this.style && typeof this.style === "object" && this.style.name && this.style.version) {
45631
45618
  return this.style;
@@ -45638,6 +45625,23 @@ uniform ${i3} ${a3} u_${s3};
45638
45625
  }
45639
45626
  return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
45640
45627
  }
45628
+ // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
45629
+ // return this.get('queryRenderedFeaturesOptions');
45630
+ // }
45631
+ // set queryRenderedFeaturesOptions(
45632
+ // newValue: maplibregl.QueryRenderedFeaturesOptions,
45633
+ // ) {
45634
+ // this.set('queryRenderedFeaturesOptions', newValue);
45635
+ // }
45636
+ setMapInternal(map) {
45637
+ if (map) {
45638
+ super.setMapInternal(map);
45639
+ this.attachToMap();
45640
+ } else {
45641
+ this.detachFromMap();
45642
+ super.setMapInternal(map);
45643
+ }
45644
+ }
45641
45645
  updateMaplibreMap() {
45642
45646
  try {
45643
45647
  this.mapLibreMap?.setStyle(this.getStyle(), { diff: false });
@@ -45779,7 +45783,7 @@ uniform ${i3} ${a3} u_${s3};
45779
45783
  console.warn(...messages);
45780
45784
  }, 1e3);
45781
45785
  }
45782
- var MaplibreStyleLayer = class _MaplibreStyleLayer extends MobilityLayerMixin_default(Layer_default) {
45786
+ var MaplibreStyleLayer = class _MaplibreStyleLayer extends Layer_default {
45783
45787
  /**
45784
45788
  * Constructor.
45785
45789
  *
@@ -45818,7 +45822,10 @@ uniform ${i3} ${a3} u_${s3};
45818
45822
  }
45819
45823
  super({ source: new Source_default({}), ...options });
45820
45824
  this.highlightedFeatures = [];
45825
+ this.olEventsKeys = [];
45821
45826
  this.selectedFeatures = [];
45827
+ defineDeprecatedProperties_default(this, options);
45828
+ this.set("options", options);
45822
45829
  this.beforeId = options.beforeId;
45823
45830
  this.onLoad = this.onLoad.bind(this);
45824
45831
  if (!this.layersFilter && this.layers) {
@@ -45888,16 +45895,16 @@ uniform ${i3} ${a3} u_${s3};
45888
45895
  * @override
45889
45896
  */
45890
45897
  attachToMap(map) {
45891
- if (this.maplibreLayer && !this.maplibreLayer.map) {
45898
+ if (this.maplibreLayer && !this.maplibreLayer.getMapInternal()) {
45892
45899
  map.addLayer(this.maplibreLayer);
45893
45900
  }
45894
- super.attachToMap(map);
45895
- if (!this.map || !this.maplibreLayer) {
45901
+ const mapInternal = this.getMapInternal();
45902
+ if (!mapInternal || !this.maplibreLayer) {
45896
45903
  return;
45897
45904
  }
45898
- if (!this.map.getTargetElement()) {
45905
+ if (!mapInternal.getTargetElement()) {
45899
45906
  this.olEventsKeys.push(
45900
- this.map.on("change:target", () => {
45907
+ mapInternal.on("change:target", () => {
45901
45908
  this.attachToMap(map);
45902
45909
  })
45903
45910
  );
@@ -45943,7 +45950,7 @@ uniform ${i3} ${a3} u_${s3};
45943
45950
  * @public
45944
45951
  */
45945
45952
  clone(newOptions) {
45946
- return new _MaplibreStyleLayer({ ...this.options, ...newOptions });
45953
+ return new _MaplibreStyleLayer({ ...this.get("options"), ...newOptions });
45947
45954
  }
45948
45955
  createRenderer() {
45949
45956
  return new MaplibreStyleLayerRenderer(this);
@@ -45953,12 +45960,12 @@ uniform ${i3} ${a3} u_${s3};
45953
45960
  * @override
45954
45961
  */
45955
45962
  detachFromMap() {
45963
+ unByKey(this.olEventsKeys);
45956
45964
  if (this.maplibreLayer?.mapLibreMap) {
45957
45965
  this.maplibreLayer.mapLibreMap.off("load", this.onLoad);
45958
45966
  this.removeLayers();
45959
45967
  this.removeSources();
45960
45968
  }
45961
- super.detachFromMap();
45962
45969
  }
45963
45970
  /**
45964
45971
  * Request feature information for a given coordinate.
@@ -46109,6 +46116,15 @@ uniform ${i3} ${a3} u_${s3};
46109
46116
  );
46110
46117
  this.setFeatureState(features, { hover: state });
46111
46118
  }
46119
+ setMapInternal(map) {
46120
+ if (map) {
46121
+ super.setMapInternal(map);
46122
+ this.attachToMap(map);
46123
+ } else {
46124
+ this.detachFromMap();
46125
+ super.setMapInternal(map);
46126
+ }
46127
+ }
46112
46128
  get beforeId() {
46113
46129
  return this.get("beforeId");
46114
46130
  }
@@ -47002,7 +47018,7 @@ uniform ${i3} ${a3} u_${s3};
47002
47018
 
47003
47019
  // src/ol/layers/RealtimeLayer.ts
47004
47020
  var format2 = new GeoJSON_default();
47005
- var RealtimeLayer = class _RealtimeLayer extends MobilityLayerMixin_default(Layer_default) {
47021
+ var RealtimeLayer = class _RealtimeLayer extends Layer_default {
47006
47022
  /**
47007
47023
  * Constructor.
47008
47024
  *
@@ -47020,6 +47036,8 @@ uniform ${i3} ${a3} u_${s3};
47020
47036
  });
47021
47037
  this.allowRenderWhenAnimating = false;
47022
47038
  this.maxNbFeaturesRequested = 100;
47039
+ this.olEventsKeys = [];
47040
+ defineDeprecatedProperties_default(this, options);
47023
47041
  this.engine = new RealtimeEngine_default({
47024
47042
  getViewState: this.getViewState.bind(this),
47025
47043
  onRender: this.onRealtimeEngineRender.bind(this),
@@ -47041,17 +47059,17 @@ uniform ${i3} ${a3} u_${s3};
47041
47059
  this.onZoomEndDebounced = (0, import_lodash6.default)(this.onZoomEnd, 100);
47042
47060
  this.onMoveEndDebounced = (0, import_lodash6.default)(this.onMoveEnd, 100);
47043
47061
  }
47044
- attachToMap(map) {
47045
- super.attachToMap(map);
47062
+ attachToMap() {
47046
47063
  this.engine.attachToMap();
47047
- if (this.map) {
47064
+ const mapInternal = this.getMapInternal();
47065
+ if (mapInternal) {
47048
47066
  if (this.getVisible()) {
47049
47067
  this.engine.start();
47050
47068
  }
47051
- const index = this.map.getLayers().getArray().indexOf(this);
47052
- this.map.getLayers().insertAt(index, this.vectorLayer);
47069
+ const index = mapInternal.getLayers().getArray().indexOf(this);
47070
+ mapInternal.getLayers().insertAt(index, this.vectorLayer);
47053
47071
  this.olEventsKeys.push(
47054
- ...this.map.on(
47072
+ ...mapInternal.on(
47055
47073
  ["moveend", "change:target"],
47056
47074
  // @ts-expect-error - bad ol definitions
47057
47075
  (evt) => {
@@ -47092,7 +47110,7 @@ uniform ${i3} ${a3} u_${s3};
47092
47110
  * @public
47093
47111
  */
47094
47112
  clone(newOptions) {
47095
- return new _RealtimeLayer({ ...this.options, ...newOptions });
47113
+ return new _RealtimeLayer({ ...this.get("options"), ...newOptions });
47096
47114
  }
47097
47115
  createRenderer() {
47098
47116
  return new RealtimeLayerRenderer(this);
@@ -47101,9 +47119,9 @@ uniform ${i3} ${a3} u_${s3};
47101
47119
  * Destroy the container of the tracker.
47102
47120
  */
47103
47121
  detachFromMap() {
47104
- this.map?.removeLayer(this.vectorLayer);
47122
+ unByKey(this.olEventsKeys);
47123
+ this.getMapInternal()?.removeLayer(this.vectorLayer);
47105
47124
  this.engine.detachFromMap();
47106
- super.detachFromMap();
47107
47125
  }
47108
47126
  /**
47109
47127
  * Get some informations about a trajectory.
@@ -47118,7 +47136,7 @@ uniform ${i3} ${a3} u_${s3};
47118
47136
  id,
47119
47137
  this.engine.mode,
47120
47138
  this.engine.getGeneralizationLevelByZoom(
47121
- Math.floor(this.map?.getView()?.getZoom() || 0)
47139
+ Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
47122
47140
  )
47123
47141
  )
47124
47142
  ];
@@ -47134,17 +47152,18 @@ uniform ${i3} ${a3} u_${s3};
47134
47152
  return this.engine.getVehicles(filterFunc);
47135
47153
  }
47136
47154
  getViewState() {
47137
- if (!this.map?.getView()) {
47155
+ const mapInternal = this.getMapInternal();
47156
+ if (!mapInternal?.getView()) {
47138
47157
  return {};
47139
47158
  }
47140
- const view = this.map.getView();
47159
+ const view = mapInternal.getView();
47141
47160
  return {
47142
47161
  center: view.getCenter(),
47143
47162
  extent: view.calculateExtent(),
47144
47163
  pixelRatio: this.engine.pixelRatio,
47145
47164
  resolution: view.getResolution(),
47146
47165
  rotation: view.getRotation(),
47147
- size: this.map.getSize(),
47166
+ size: mapInternal.getSize(),
47148
47167
  visible: this.getVisible(),
47149
47168
  zoom: view.getZoom()
47150
47169
  };
@@ -47168,7 +47187,7 @@ uniform ${i3} ${a3} u_${s3};
47168
47187
  id,
47169
47188
  this.engine.mode,
47170
47189
  this.engine.getGeneralizationLevelByZoom(
47171
- Math.floor(this.map?.getView()?.getZoom() || 0)
47190
+ Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
47172
47191
  )
47173
47192
  ).then((data) => {
47174
47193
  const fullTrajectory = data.content;
@@ -47219,8 +47238,17 @@ uniform ${i3} ${a3} u_${s3};
47219
47238
  }
47220
47239
  this.highlightTrajectory(id);
47221
47240
  }
47241
+ setMapInternal(map) {
47242
+ if (map) {
47243
+ super.setMapInternal(map);
47244
+ this.attachToMap();
47245
+ } else {
47246
+ this.detachFromMap();
47247
+ super.setMapInternal(map);
47248
+ }
47249
+ }
47222
47250
  shouldRender() {
47223
- return this.allowRenderWhenAnimating ? false : this.map.getView().getAnimating() || this.map.getView().getInteracting();
47251
+ return this.allowRenderWhenAnimating ? false : this.getMapInternal()?.getView().getAnimating() || this.getMapInternal()?.getView().getInteracting();
47224
47252
  }
47225
47253
  /**
47226
47254
  * Start the rendering.
@@ -47303,14 +47331,15 @@ uniform ${i3} ${a3} u_${s3};
47303
47331
  return null;
47304
47332
  }
47305
47333
  };
47306
- var Layer2 = class _Layer extends MobilityLayerMixin_default(Layer_default) {
47334
+ var Layer2 = class _Layer extends Layer_default {
47307
47335
  constructor(options) {
47308
47336
  super(options);
47337
+ defineDeprecatedProperties_default(this, options);
47309
47338
  deprecated4("Layer is deprecated. Use an OpenLayers Layer instead.");
47310
47339
  }
47311
47340
  clone(newOptions) {
47312
47341
  return new _Layer({
47313
- ...this.options || {},
47342
+ ...this.get("options") || {},
47314
47343
  ...newOptions || {}
47315
47344
  });
47316
47345
  }
@@ -47327,18 +47356,19 @@ uniform ${i3} ${a3} u_${s3};
47327
47356
  * @deprecated
47328
47357
  */
47329
47358
  clone(newOptions) {
47330
- return new _VectorLayer({ ...this.options, ...newOptions });
47359
+ return new _VectorLayer({ ...this.get("options"), ...newOptions });
47331
47360
  }
47332
47361
  /**
47333
47362
  * @deprecated
47334
47363
  */
47335
47364
  getFeatureInfoAtCoordinate(coordinate) {
47336
47365
  let features = [];
47337
- if (this.map) {
47338
- const pixel = this.map.getPixelFromCoordinate(coordinate);
47339
- features = this.map.getFeaturesAtPixel(pixel, {
47340
- hitTolerance: this.hitTolerance || 5,
47341
- layerFilter: (l) => l === this.olLayer
47366
+ const mapInternal = this.getMapInternal();
47367
+ if (mapInternal) {
47368
+ const pixel = mapInternal.getPixelFromCoordinate(coordinate);
47369
+ features = mapInternal.getFeaturesAtPixel(pixel, {
47370
+ hitTolerance: this.get("hitTolerance") || 5,
47371
+ layerFilter: (l) => l === this
47342
47372
  }) || [];
47343
47373
  }
47344
47374
  return Promise.resolve({