mobility-toolbox-js 3.0.0-beta.13 → 3.0.0-beta.15

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
@@ -423,7 +423,7 @@
423
423
  var now = function() {
424
424
  return root.Date.now();
425
425
  };
426
- function debounce4(func, wait, options) {
426
+ function debounce5(func, wait, options) {
427
427
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
428
428
  if (typeof func != "function") {
429
429
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -531,7 +531,7 @@
531
531
  var isBinary = reIsBinary.test(value);
532
532
  return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
533
533
  }
534
- module.exports = debounce4;
534
+ module.exports = debounce5;
535
535
  }
536
536
  });
537
537
 
@@ -17725,7 +17725,7 @@ uniform ${i3} ${s3} u_${a3};
17725
17725
  var now = function() {
17726
17726
  return root.Date.now();
17727
17727
  };
17728
- function debounce4(func, wait, options) {
17728
+ function debounce5(func, wait, options) {
17729
17729
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
17730
17730
  if (typeof func != "function") {
17731
17731
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -17814,7 +17814,7 @@ uniform ${i3} ${s3} u_${a3};
17814
17814
  leading = "leading" in options ? !!options.leading : leading;
17815
17815
  trailing = "trailing" in options ? !!options.trailing : trailing;
17816
17816
  }
17817
- return debounce4(func, wait, {
17817
+ return debounce5(func, wait, {
17818
17818
  "leading": leading,
17819
17819
  "maxWait": wait,
17820
17820
  "trailing": trailing
@@ -17868,6 +17868,7 @@ uniform ${i3} ${s3} u_${a3};
17868
17868
  StopFinderControl: () => StopFinderControl_default,
17869
17869
  StopsAPI: () => StopsAPI_default,
17870
17870
  VECTOR_TILE_FEATURE_PROPERTY: () => VECTOR_TILE_FEATURE_PROPERTY,
17871
+ VectorLayer: () => VectorLayer_default2,
17871
17872
  compareDepartures: () => compareDepartures_default,
17872
17873
  createCanvas: () => createCanvas_default,
17873
17874
  createRealtimeFilters: () => createRealtimeFilters_default,
@@ -44250,24 +44251,232 @@ uniform ${i3} ${s3} u_${a3};
44250
44251
  var StopFinderControl_default = StopFinderControl;
44251
44252
 
44252
44253
  // src/ol/layers/MaplibreLayer.ts
44253
- var import_lodash = __toESM(require_lodash());
44254
- var import_maplibre_gl = __toESM(require_maplibre_gl());
44254
+ var import_lodash2 = __toESM(require_lodash());
44255
+
44256
+ // node_modules/@geoblocks/ol-maplibre-layer/lib/MapLibreLayer.js
44257
+ var import_maplibre_gl = __toESM(require_maplibre_gl(), 1);
44258
+
44259
+ // node_modules/@geoblocks/ol-maplibre-layer/lib/MapLibreLayerRenderer.js
44260
+ var VECTOR_TILE_FEATURE_PROPERTY2 = "vectorTileFeature";
44261
+ var formats = {
44262
+ "EPSG:3857": new GeoJSON_default({
44263
+ featureProjection: "EPSG:3857"
44264
+ })
44265
+ };
44266
+ var MapLibreLayerRenderer = class extends Layer_default2 {
44267
+ getFeaturesAtCoordinate(coordinate, hitTolerance = 5) {
44268
+ const pixels = this.getMapLibrePixels(coordinate, hitTolerance);
44269
+ if (!pixels) {
44270
+ return [];
44271
+ }
44272
+ const queryRenderedFeaturesOptions = this.getLayer().get("queryRenderedFeaturesOptions") || {};
44273
+ const features = this.getLayer().mapLibreMap?.queryRenderedFeatures(pixels, queryRenderedFeaturesOptions).map((feature2) => {
44274
+ return this.toOlFeature(feature2);
44275
+ });
44276
+ return features || [];
44277
+ }
44278
+ prepareFrame() {
44279
+ return true;
44280
+ }
44281
+ renderFrame(frameState) {
44282
+ const layer = this.getLayer();
44283
+ const { mapLibreMap } = layer;
44284
+ const map = layer.getMapInternal();
44285
+ if (!layer || !map || !mapLibreMap) {
44286
+ return null;
44287
+ }
44288
+ const mapLibreCanvas = mapLibreMap.getCanvas();
44289
+ const { viewState } = frameState;
44290
+ mapLibreMap.jumpTo({
44291
+ center: toLonLat(viewState.center),
44292
+ zoom: viewState.zoom - 1,
44293
+ bearing: toDegrees(-viewState.rotation)
44294
+ });
44295
+ const opacity = layer.getOpacity().toString();
44296
+ if (mapLibreCanvas && opacity !== mapLibreCanvas.style.opacity) {
44297
+ mapLibreCanvas.style.opacity = opacity;
44298
+ }
44299
+ if (!mapLibreCanvas.isConnected) {
44300
+ map.render();
44301
+ } else if (!sameSize(mapLibreCanvas, frameState)) {
44302
+ mapLibreMap.resize();
44303
+ }
44304
+ mapLibreMap.redraw();
44305
+ return mapLibreMap.getContainer();
44306
+ }
44307
+ getFeatures(pixel) {
44308
+ const coordinate = this.getLayer().getMapInternal()?.getCoordinateFromPixel(pixel);
44309
+ return Promise.resolve(this.getFeaturesAtCoordinate(coordinate));
44310
+ }
44311
+ forEachFeatureAtCoordinate(coordinate, _frameState, hitTolerance, callback) {
44312
+ const features = this.getFeaturesAtCoordinate(coordinate, hitTolerance);
44313
+ features.forEach((feature2) => {
44314
+ const geometry = feature2.getGeometry();
44315
+ if (geometry instanceof SimpleGeometry_default) {
44316
+ callback(feature2, this.layer_, geometry);
44317
+ }
44318
+ });
44319
+ return features?.[0];
44320
+ }
44321
+ getMapLibrePixels(coordinate, hitTolerance) {
44322
+ if (!coordinate) {
44323
+ return void 0;
44324
+ }
44325
+ const pixel = this.getLayer().mapLibreMap?.project(toLonLat(coordinate));
44326
+ if (pixel?.x === void 0 || pixel?.y === void 0) {
44327
+ return void 0;
44328
+ }
44329
+ let pixels = [
44330
+ pixel.x,
44331
+ pixel.y
44332
+ ];
44333
+ if (hitTolerance) {
44334
+ const [x, y] = pixels;
44335
+ pixels = [
44336
+ [x - hitTolerance, y - hitTolerance],
44337
+ [x + hitTolerance, y + hitTolerance]
44338
+ ];
44339
+ }
44340
+ return pixels;
44341
+ }
44342
+ toOlFeature(feature2) {
44343
+ const layer = this.getLayer();
44344
+ const map = layer.getMapInternal();
44345
+ const projection = map?.getView()?.getProjection()?.getCode() || "EPSG:3857";
44346
+ if (!formats[projection]) {
44347
+ formats[projection] = new GeoJSON_default({
44348
+ featureProjection: projection
44349
+ });
44350
+ }
44351
+ const olFeature = formats[projection].readFeature(feature2);
44352
+ if (olFeature) {
44353
+ olFeature.set(VECTOR_TILE_FEATURE_PROPERTY2, feature2, true);
44354
+ }
44355
+ return olFeature;
44356
+ }
44357
+ };
44358
+ function sameSize(canvas2, frameState) {
44359
+ return canvas2.width === Math.floor(frameState.size[0] * frameState.pixelRatio) && canvas2.height === Math.floor(frameState.size[1] * frameState.pixelRatio);
44360
+ }
44361
+
44362
+ // node_modules/@geoblocks/ol-maplibre-layer/lib/getMapLibreAttributions.js
44363
+ var getMapLibreAttributions = (map) => {
44364
+ if (!map) {
44365
+ return [];
44366
+ }
44367
+ const { style } = map;
44368
+ if (!style) {
44369
+ return [];
44370
+ }
44371
+ const { sourceCaches } = style;
44372
+ let copyrights = [];
44373
+ Object.values(sourceCaches).forEach((value) => {
44374
+ if (value.used) {
44375
+ const { attribution } = value.getSource();
44376
+ if (attribution) {
44377
+ copyrights = copyrights.concat(attribution.replace(/&copy;/g, "\xA9").split(/(<a.*?<\/a>)/));
44378
+ }
44379
+ }
44380
+ });
44381
+ return removeDuplicate2(copyrights);
44382
+ };
44383
+ var removeDuplicate2 = (array) => {
44384
+ const arrWithoutEmptyValues = array.filter((val) => val !== void 0 && val !== null && val.trim && val.trim());
44385
+ const lowerCasesValues = arrWithoutEmptyValues.map((str) => str.toLowerCase());
44386
+ const uniqueLowerCaseValues = [...new Set(lowerCasesValues)];
44387
+ return uniqueLowerCaseValues.map((uniqueStr) => arrWithoutEmptyValues.find((str) => str.toLowerCase() === uniqueStr));
44388
+ };
44389
+ var getMapLibreAttributions_default = getMapLibreAttributions;
44390
+
44391
+ // node_modules/@geoblocks/ol-maplibre-layer/lib/MapLibreLayer.js
44392
+ var MapLibreLayer = class extends Layer_default {
44393
+ mapLibreMap;
44394
+ loaded = false;
44395
+ olListenersKeys = [];
44396
+ constructor(options) {
44397
+ super({
44398
+ source: new Source_default({
44399
+ attributions: () => {
44400
+ return getMapLibreAttributions_default(this.mapLibreMap);
44401
+ }
44402
+ }),
44403
+ ...options
44404
+ });
44405
+ }
44406
+ disposeInternal() {
44407
+ unByKey(this.olListenersKeys);
44408
+ this.loaded = false;
44409
+ if (this.mapLibreMap) {
44410
+ this.mapLibreMap.triggerRepaint = () => {
44411
+ };
44412
+ this.mapLibreMap.remove();
44413
+ }
44414
+ super.disposeInternal();
44415
+ }
44416
+ setMapInternal(map) {
44417
+ super.setMapInternal(map);
44418
+ if (map) {
44419
+ this.loadMapLibreMap();
44420
+ } else {
44421
+ this.dispose();
44422
+ }
44423
+ }
44424
+ loadMapLibreMap() {
44425
+ this.loaded = false;
44426
+ const map = this.getMapInternal();
44427
+ if (map) {
44428
+ this.olListenersKeys.push(map.on("change:target", this.loadMapLibreMap.bind(this)));
44429
+ }
44430
+ if (!map?.getTargetElement()) {
44431
+ return;
44432
+ }
44433
+ if (!this.getVisible()) {
44434
+ this.olListenersKeys.push(this.once("change:visible", this.loadMapLibreMap.bind(this)));
44435
+ return;
44436
+ }
44437
+ const container = document.createElement("div");
44438
+ container.style.position = "absolute";
44439
+ container.style.width = "100%";
44440
+ container.style.height = "100%";
44441
+ const mapLibreOptions = this.get("mapLibreOptions");
44442
+ this.mapLibreMap = new import_maplibre_gl.Map(Object.assign({}, mapLibreOptions, {
44443
+ container,
44444
+ attributionControl: false,
44445
+ interactive: false,
44446
+ trackResize: false
44447
+ }));
44448
+ this.mapLibreMap.on("sourcedata", () => {
44449
+ this.getSource()?.refresh();
44450
+ });
44451
+ this.mapLibreMap.once("load", () => {
44452
+ this.loaded = true;
44453
+ this.dispatchEvent(new Event_default("load"));
44454
+ });
44455
+ }
44456
+ createRenderer() {
44457
+ return new MapLibreLayerRenderer(this);
44458
+ }
44459
+ };
44255
44460
 
44256
44461
  // src/ol/mixins/PropertiesLayerMixin.ts
44462
+ var import_lodash = __toESM(require_lodash());
44463
+ var deprecated = (0, import_lodash.default)((message) => {
44464
+ console.warn(message);
44465
+ }, 1e3);
44257
44466
  function PropertiesLayerMixin(Base) {
44258
44467
  return class PropertiesLayer extends Base {
44259
44468
  constructor(...args) {
44260
44469
  const options = args[0];
44261
44470
  super(options);
44262
44471
  this.options = {};
44263
- this.olListenersKeys = [];
44472
+ this.olEventsKeys = [];
44264
44473
  if (options.properties) {
44265
- console.warn(
44474
+ deprecated(
44266
44475
  "Deprecated. Don't use properties options. Pass the values directly in options object."
44267
44476
  );
44268
44477
  this.setProperties(options.properties);
44269
44478
  }
44270
- this.olListenersKeys?.push(
44479
+ this.olEventsKeys?.push(
44271
44480
  // Update parent property
44272
44481
  this.on("propertychange", (evt) => {
44273
44482
  if (evt.key === "children") {
@@ -44278,33 +44487,60 @@ uniform ${i3} ${s3} u_${a3};
44278
44487
  this.options = options;
44279
44488
  this.children = options.children || [];
44280
44489
  }
44490
+ /** @deprecated */
44281
44491
  get children() {
44492
+ deprecated(
44493
+ "Layer.children is deprecated. Use the Layer.get('children') method instead."
44494
+ );
44282
44495
  return this.get("children") || [];
44283
44496
  }
44497
+ /** @deprecated */
44284
44498
  set children(newValue) {
44499
+ deprecated(
44500
+ "Layer.children is deprecated. Use the Layer.set('children', children) method instead."
44501
+ );
44285
44502
  this.set("children", newValue || []);
44286
44503
  }
44504
+ /** @deprecated */
44287
44505
  get copyrights() {
44288
- console.warn("Deprecated. Use the source object to get the attributions");
44506
+ deprecated(
44507
+ "Layer.copyrights is deprecated. Get the attributions from the source object"
44508
+ );
44289
44509
  return this.get("copyrights");
44290
44510
  }
44511
+ /** @deprecated */
44291
44512
  set copyrights(newCopyrights) {
44292
- console.warn("Deprecated. Use the source object to set the attributions");
44513
+ deprecated(
44514
+ "Layer.copyrights is deprecated. Set the attributions to the source object."
44515
+ );
44293
44516
  const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
44294
44517
  this.set("copyrights", arrValue || []);
44295
44518
  }
44519
+ /** @deprecated */
44296
44520
  get disabled() {
44521
+ deprecated(
44522
+ "Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."
44523
+ );
44297
44524
  return this.get("disabled");
44298
44525
  }
44526
+ /** @deprecated */
44299
44527
  set disabled(newValue) {
44528
+ deprecated(
44529
+ "Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."
44530
+ );
44300
44531
  this.set("disabled", newValue);
44301
44532
  }
44533
+ /** @deprecated */
44302
44534
  get group() {
44535
+ deprecated(
44536
+ "Layer.group is deprecated. Use the Layer.get('group') method instead."
44537
+ );
44303
44538
  return this.get("group");
44304
44539
  }
44540
+ /** @deprecated */
44305
44541
  get hitTolerance() {
44306
- console.warn(
44307
- "Deprecated. Pass the pixelTolerance when you request the features."
44542
+ deprecated(
44543
+ "Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."
44308
44544
  );
44309
44545
  return this.get("hitTolerance") || 5;
44310
44546
  }
@@ -44314,31 +44550,53 @@ uniform ${i3} ${s3} u_${a3};
44314
44550
  get map() {
44315
44551
  return this.getMapInternal();
44316
44552
  }
44553
+ /** @deprecated */
44317
44554
  get name() {
44555
+ deprecated(
44556
+ "Layer.name is deprecated. Use the Layer.get('name') method instead."
44557
+ );
44318
44558
  return this.get("name");
44319
44559
  }
44560
+ /** @deprecated */
44320
44561
  get olLayer() {
44321
- console.warn(
44322
- "Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."
44562
+ deprecated(
44563
+ "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."
44323
44564
  );
44324
44565
  return this;
44325
44566
  }
44567
+ /** @deprecated */
44326
44568
  // eslint-disable-next-line class-methods-use-this
44327
44569
  set olLayer(newValue) {
44328
- console.log(
44329
- "Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect."
44570
+ deprecated(
44571
+ "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect."
44330
44572
  );
44331
44573
  }
44574
+ /** @deprecated */
44332
44575
  get parent() {
44576
+ deprecated(
44577
+ "Layer.parent is deprecated. Use the Layer.get('parent') method instead."
44578
+ );
44333
44579
  return this.get("parent");
44334
44580
  }
44581
+ /** @deprecated */
44335
44582
  set parent(newValue) {
44583
+ deprecated(
44584
+ "Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."
44585
+ );
44336
44586
  this.set("parent", newValue);
44337
44587
  }
44588
+ /** @deprecated */
44338
44589
  get visible() {
44590
+ deprecated(
44591
+ "Layer.visible is deprecated. Use the Layer.getVisible() method instead."
44592
+ );
44339
44593
  return this.getVisible();
44340
44594
  }
44595
+ /** @deprecated */
44341
44596
  set visible(newValue) {
44597
+ deprecated(
44598
+ "Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."
44599
+ );
44342
44600
  this.setVisible(newValue);
44343
44601
  }
44344
44602
  // @ts-expect-error - this is a mixin
@@ -44383,8 +44641,12 @@ uniform ${i3} ${s3} u_${a3};
44383
44641
  }
44384
44642
  /**
44385
44643
  * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
44644
+ * @deprecated
44386
44645
  */
44387
44646
  flat() {
44647
+ deprecated(
44648
+ "Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."
44649
+ );
44388
44650
  return getLayersAsFlatArray_default(this);
44389
44651
  }
44390
44652
  };
@@ -44401,121 +44663,24 @@ uniform ${i3} ${s3} u_${a3};
44401
44663
  }
44402
44664
  var MobilityLayerMixin_default = MobilityLayerMixin;
44403
44665
 
44404
- // src/ol/renderers/MaplibreLayerRenderer.ts
44405
- var formats = {
44406
- "EPSG:3857": new GeoJSON_default({
44407
- featureProjection: "EPSG:3857"
44408
- })
44409
- };
44410
- var MaplibreLayerRenderer = class extends Layer_default2 {
44411
- getFeaturesAtCoordinate(coordinate, hitTolerance = 5) {
44412
- if (!coordinate) {
44413
- return [];
44414
- }
44415
- const layer = this.getLayer();
44416
- const map = layer.getMapInternal();
44417
- const { mbMap } = layer;
44418
- const projection = map?.getView()?.getProjection()?.getCode() || "EPSG:3857";
44419
- let features = [];
44420
- if (!formats[projection]) {
44421
- formats[projection] = new GeoJSON_default({
44422
- featureProjection: projection
44423
- });
44424
- }
44425
- if (mbMap?.isStyleLoaded()) {
44426
- const pixel = coordinate && mbMap.project(toLonLat(coordinate));
44427
- if (pixel?.x && pixel?.y) {
44428
- let pixels = [
44429
- pixel.x,
44430
- pixel.y
44431
- ];
44432
- if (hitTolerance) {
44433
- const [x, y] = pixels;
44434
- pixels = [
44435
- [x - hitTolerance, y - hitTolerance],
44436
- [x + hitTolerance, y + hitTolerance]
44437
- ];
44438
- }
44439
- features = mbMap.queryRenderedFeatures(
44440
- pixels,
44441
- layer.queryRenderedFeaturesOptions || {}
44442
- ).map((feature2) => {
44443
- const olFeature = formats[projection].readFeature(
44444
- feature2
44445
- );
44446
- if (olFeature) {
44447
- olFeature.set(VECTOR_TILE_FEATURE_PROPERTY, feature2);
44448
- }
44449
- return olFeature;
44450
- });
44451
- }
44452
- }
44453
- return features;
44454
- }
44455
- // eslint-disable-next-line class-methods-use-this
44456
- prepareFrame() {
44457
- return true;
44458
- }
44459
- renderFrame(frameState) {
44460
- const layer = this.getLayer();
44461
- const { map, mbMap } = layer;
44462
- if (!layer || !map || !mbMap) {
44463
- return null;
44464
- }
44465
- const canvas2 = mbMap.getCanvas();
44466
- const { viewState } = frameState;
44467
- const opacity = layer.getOpacity() || 1;
44468
- canvas2.style.opacity = `${opacity}`;
44469
- mbMap.jumpTo({
44470
- center: toLonLat(viewState.center),
44471
- zoom: viewState.zoom - 1,
44472
- bearing: toDegrees(-viewState.rotation)
44473
- });
44474
- if (!canvas2.isConnected) {
44475
- map.render();
44476
- } else if (canvas2.width !== frameState.size[0] || canvas2.height !== frameState.size[1]) {
44477
- mbMap.resize();
44478
- }
44479
- mbMap.redraw();
44480
- return mbMap.getContainer();
44481
- }
44482
- getFeatures(pixel) {
44483
- const coordinate = this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(pixel);
44484
- return Promise.resolve(this.getFeaturesAtCoordinate(coordinate));
44485
- }
44486
- forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback) {
44487
- const features = this.getFeaturesAtCoordinate(coordinate, hitTolerance);
44488
- features.forEach((feature2) => {
44489
- callback(feature2, this.layer_, feature2.getGeometry());
44490
- });
44491
- return features?.[0];
44492
- }
44493
- };
44494
-
44495
44666
  // src/ol/layers/MaplibreLayer.ts
44496
- var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(Layer_default) {
44497
- get apiKey() {
44498
- return this.get("apiKey");
44499
- }
44500
- set apiKey(newValue) {
44501
- this.set("apiKey", newValue);
44502
- }
44503
- get apiKeyName() {
44504
- return this.get("apiKeyName");
44505
- }
44506
- set apiKeyName(newValue) {
44507
- this.set("apiKeyName", newValue);
44508
- }
44667
+ var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(MapLibreLayer) {
44509
44668
  get mbMap() {
44510
44669
  console.warn("Deprecated. Use layer.maplibreMap.");
44511
44670
  return this.maplibreMap;
44512
44671
  }
44513
- get queryRenderedFeaturesOptions() {
44514
- return this.get("queryRenderedFeaturesOptions");
44515
- }
44516
- set queryRenderedFeaturesOptions(newValue) {
44517
- this.set("queryRenderedFeaturesOptions", newValue);
44672
+ get maplibreMap() {
44673
+ console.warn("Deprecated. Use layer.mapLibreMap.");
44674
+ return this.mapLibreMap;
44518
44675
  }
44676
+ // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
44677
+ // return this.get('queryRenderedFeaturesOptions');
44678
+ // }
44679
+ // set queryRenderedFeaturesOptions(
44680
+ // newValue: maplibregl.QueryRenderedFeaturesOptions,
44681
+ // ) {
44682
+ // this.set('queryRenderedFeaturesOptions', newValue);
44683
+ // }
44519
44684
  get style() {
44520
44685
  return this.get("style");
44521
44686
  }
@@ -44534,30 +44699,18 @@ uniform ${i3} ${s3} u_${a3};
44534
44699
  * @param {MaplibreLayerOptions} options
44535
44700
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
44536
44701
  * @param {string} [options.apiKeyName="key"] The geOps Maps API key name.
44537
- * @param {maplibregl.MapOptions} [options.mapOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
44702
+ * @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
44538
44703
  * @param {string} [options.style="travic_v2"] The geOps Maps API style.
44539
44704
  * @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
44540
44705
  */
44541
44706
  constructor(options) {
44542
44707
  super({
44543
- source: new Source_default({
44544
- attributions: () => {
44545
- return this.maplibreMap && getMapGlCopyrights_default(this.maplibreMap) || [];
44546
- }
44547
- }),
44548
44708
  apiKeyName: "key",
44549
44709
  style: "travic_v2",
44550
44710
  url: "https://maps.geops.io",
44551
44711
  ...options || {},
44552
- // @ts-expect-error mapOptions must be saved by the mixin in this.options
44553
- mapOptions: {
44554
- interactive: false,
44555
- trackResize: false,
44556
- attributionControl: false,
44557
- ...options?.mapOptions || {}
44558
- },
44559
- queryRenderedFeaturesOptions: {
44560
- ...options?.queryRenderedFeaturesOptions || {}
44712
+ mapLibreOptions: {
44713
+ ...options.mapLibreOptions || {}
44561
44714
  }
44562
44715
  });
44563
44716
  }
@@ -44567,69 +44720,19 @@ uniform ${i3} ${s3} u_${a3};
44567
44720
  */
44568
44721
  attachToMap(map) {
44569
44722
  super.attachToMap(map);
44570
- this.loadMbMap();
44571
- const updateMaplibreMapDebounced = (0, import_lodash.default)(
44723
+ this.updateMaplibreMap();
44724
+ const updateMaplibreMapDebounced = (0, import_lodash2.default)(
44572
44725
  this.updateMaplibreMap.bind(this),
44573
44726
  150
44574
44727
  );
44575
- this.olListenersKeys.push(
44728
+ this.olEventsKeys.push(
44576
44729
  this.on("propertychange", (evt) => {
44577
- if (/(apiKey|apiKeyName|url|style)/.test(evt.key)) {
44730
+ if (/(url|style)/.test(evt.key)) {
44578
44731
  updateMaplibreMapDebounced();
44579
44732
  }
44580
44733
  })
44581
44734
  );
44582
44735
  }
44583
- /**
44584
- * Terminate what was initialized in init function. Remove layer, events...
44585
- */
44586
- detachFromMap() {
44587
- if (this.maplibreMap) {
44588
- this.maplibreMap.triggerRepaint = () => {
44589
- };
44590
- this.maplibreMap.remove();
44591
- this.maplibreMap = void 0;
44592
- }
44593
- this.loaded = false;
44594
- super.detachFromMap();
44595
- }
44596
- /**
44597
- * Create the Maplibre map.
44598
- * @private
44599
- */
44600
- loadMbMap() {
44601
- this.loaded = false;
44602
- this.olListenersKeys.push(
44603
- // @ts-ignore
44604
- this.map?.on("change:target", this.loadMbMap.bind(this))
44605
- );
44606
- if (!this.map?.getTargetElement()) {
44607
- return;
44608
- }
44609
- if (!this.visible) {
44610
- this.olListenersKeys.push(
44611
- // @ts-ignore
44612
- this.once("change:visible", this.loadMbMap.bind(this))
44613
- );
44614
- return;
44615
- }
44616
- const container = document.createElement("div");
44617
- container.style.position = "absolute";
44618
- container.style.width = "100%";
44619
- container.style.height = "100%";
44620
- this.maplibreMap = this.createMap({
44621
- style: this.getStyle(),
44622
- container,
44623
- ...this.options?.mapOptions || {}
44624
- });
44625
- this.maplibreMap.on("sourcedata", () => {
44626
- this.getSource()?.refresh();
44627
- });
44628
- this.maplibreMap.once("load", () => {
44629
- this.loaded = true;
44630
- this.dispatchEvent(new Event_default("load"));
44631
- });
44632
- }
44633
44736
  getStyle() {
44634
44737
  if (this.style && typeof this.style === "object" && this.style.name && this.style.version) {
44635
44738
  return this.style;
@@ -44638,16 +44741,16 @@ uniform ${i3} ${s3} u_${a3};
44638
44741
  return this.url;
44639
44742
  }
44640
44743
  return getUrlWithParams_default(`${this.url}/styles/${this.style}/style.json`, {
44641
- [this.apiKeyName]: this.apiKey
44744
+ [this.get("apiKeyName")]: this.get("apiKey")
44642
44745
  }).toString();
44643
44746
  }
44644
44747
  // eslint-disable-next-line class-methods-use-this
44645
- createMap(options) {
44646
- return new import_maplibre_gl.Map(options);
44647
- }
44648
- createRenderer() {
44649
- return new MaplibreLayerRenderer(this);
44650
- }
44748
+ // createMap(options: MapOptions): Map {
44749
+ // return new Map(options);
44750
+ // }
44751
+ // createRenderer(): MaplibreLayerRenderer {
44752
+ // return new MaplibreLayerRenderer(this);
44753
+ // }
44651
44754
  updateMaplibreMap() {
44652
44755
  this.maplibreMap?.setStyle(this.getStyle(), { diff: false });
44653
44756
  }
@@ -44757,8 +44860,17 @@ uniform ${i3} ${s3} u_${a3};
44757
44860
  * @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
44758
44861
  * @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
44759
44862
  */
44760
- constructor(options) {
44761
- super({ source: new Source_default({}), ...options || {} });
44863
+ constructor(options = {
44864
+ mapLibreOptions: { style: { version: 8, sources: {}, layers: [] } }
44865
+ }) {
44866
+ if (options.mapboxLayer) {
44867
+ console.warn(
44868
+ "options.mapboxLayer is deprecated. Use options.maplibreLayer instead."
44869
+ );
44870
+ options.maplibreLayer = options.mapboxLayer;
44871
+ delete options.mapboxLayer;
44872
+ }
44873
+ super({ source: new Source_default({}), ...options });
44762
44874
  this.highlightedFeatures = [];
44763
44875
  this.selectedFeatures = [];
44764
44876
  this.onLoad = this.onLoad.bind(this);
@@ -44853,7 +44965,7 @@ uniform ${i3} ${s3} u_${a3};
44853
44965
  return;
44854
44966
  }
44855
44967
  if (!this.map.getTargetElement()) {
44856
- this.olListenersKeys.push(
44968
+ this.olEventsKeys.push(
44857
44969
  this.map.on("change:target", () => {
44858
44970
  this.attachToMap(map);
44859
44971
  })
@@ -44868,7 +44980,7 @@ uniform ${i3} ${s3} u_${a3};
44868
44980
  maplibreMap.once("load", this.onLoad);
44869
44981
  }
44870
44982
  }
44871
- this.olListenersKeys.push(
44983
+ this.olEventsKeys.push(
44872
44984
  // @ts-expect-error 'load' is a custom event
44873
44985
  this.maplibreLayer.on("load", this.onLoad.bind(this)),
44874
44986
  this.on("change:visible", (evt) => {
@@ -45131,11 +45243,11 @@ uniform ${i3} ${s3} u_${a3};
45131
45243
  var MaplibreStyleLayer_default = MaplibreStyleLayer;
45132
45244
 
45133
45245
  // src/ol/layers/RealtimeLayer.ts
45134
- var import_lodash4 = __toESM(require_lodash());
45246
+ var import_lodash5 = __toESM(require_lodash());
45135
45247
 
45136
45248
  // src/common/mixins/RealtimeLayerMixin.ts
45137
- var import_lodash2 = __toESM(require_lodash());
45138
- var import_lodash3 = __toESM(require_lodash2());
45249
+ var import_lodash3 = __toESM(require_lodash());
45250
+ var import_lodash4 = __toESM(require_lodash2());
45139
45251
  function RealtimeLayerMixin(Base) {
45140
45252
  return class Mixin extends Base {
45141
45253
  constructor(options) {
@@ -45214,12 +45326,12 @@ uniform ${i3} ${s3} u_${a3};
45214
45326
  return this.renderTimeIntervalByZoom[zoom];
45215
45327
  };
45216
45328
  this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
45217
- this.throttleRenderTrajectories = (0, import_lodash3.default)(
45329
+ this.throttleRenderTrajectories = (0, import_lodash4.default)(
45218
45330
  this.renderTrajectoriesInternal,
45219
45331
  50,
45220
45332
  { leading: false, trailing: true }
45221
45333
  );
45222
- this.debounceRenderTrajectories = (0, import_lodash2.default)(
45334
+ this.debounceRenderTrajectories = (0, import_lodash3.default)(
45223
45335
  this.renderTrajectoriesInternal,
45224
45336
  50,
45225
45337
  { leading: true, trailing: true, maxWait: 5e3 }
@@ -45629,13 +45741,13 @@ uniform ${i3} ${s3} u_${a3};
45629
45741
  const nextTick = Math.max(25, timeStep / (this.speed || 1));
45630
45742
  const nextThrottleTick = Math.min(nextTick, 500);
45631
45743
  if (this.useThrottle) {
45632
- this.throttleRenderTrajectories = (0, import_lodash3.default)(
45744
+ this.throttleRenderTrajectories = (0, import_lodash4.default)(
45633
45745
  this.renderTrajectoriesInternal,
45634
45746
  nextThrottleTick,
45635
45747
  { leading: true, trailing: true }
45636
45748
  );
45637
45749
  } else if (this.useDebounce) {
45638
- this.debounceRenderTrajectories = (0, import_lodash2.default)(
45750
+ this.debounceRenderTrajectories = (0, import_lodash3.default)(
45639
45751
  this.renderTrajectoriesInternal,
45640
45752
  nextThrottleTick,
45641
45753
  { leading: true, trailing: true, maxWait: 5e3 }
@@ -46198,8 +46310,8 @@ uniform ${i3} ${s3} u_${a3};
46198
46310
  zoom: void 0,
46199
46311
  rotation: 0
46200
46312
  };
46201
- this.onZoomEndDebounced = (0, import_lodash4.default)(this.onZoomEnd, 100);
46202
- this.onMoveEndDebounced = (0, import_lodash4.default)(this.onMoveEnd, 100);
46313
+ this.onZoomEndDebounced = (0, import_lodash5.default)(this.onZoomEnd, 100);
46314
+ this.onMoveEndDebounced = (0, import_lodash5.default)(this.onMoveEnd, 100);
46203
46315
  }
46204
46316
  /**
46205
46317
  * @private
@@ -46216,7 +46328,7 @@ uniform ${i3} ${s3} u_${a3};
46216
46328
  }
46217
46329
  const index = this.map.getLayers().getArray().indexOf(this);
46218
46330
  this.map.getLayers().insertAt(index, this.vectorLayer);
46219
- this.olListenersKeys.push(
46331
+ this.olEventsKeys.push(
46220
46332
  ...this.map.on(
46221
46333
  ["moveend", "change:target"],
46222
46334
  // @ts-expect-error - bad ol definitions
@@ -46465,6 +46577,35 @@ uniform ${i3} ${s3} u_${a3};
46465
46577
  };
46466
46578
  var Layer_default4 = Layer2;
46467
46579
 
46580
+ // src/ol/layers/VectorLayer.ts
46581
+ var VectorLayer2 = class _VectorLayer extends Layer_default4 {
46582
+ /**
46583
+ * @deprecated
46584
+ */
46585
+ getFeatureInfoAtCoordinate(coordinate) {
46586
+ let features = [];
46587
+ if (this.map) {
46588
+ const pixel = this.map.getPixelFromCoordinate(coordinate);
46589
+ features = this.map.getFeaturesAtPixel(pixel, {
46590
+ layerFilter: (l) => l === this.olLayer,
46591
+ hitTolerance: this.hitTolerance || 5
46592
+ });
46593
+ }
46594
+ return Promise.resolve({
46595
+ features,
46596
+ layer: this,
46597
+ coordinate
46598
+ });
46599
+ }
46600
+ /**
46601
+ * @deprecated
46602
+ */
46603
+ clone(newOptions) {
46604
+ return new _VectorLayer({ ...this.options, ...newOptions });
46605
+ }
46606
+ };
46607
+ var VectorLayer_default2 = VectorLayer2;
46608
+
46468
46609
  // src/ol/utils/getFeatureInfoAtCoordinate.ts
46469
46610
  var format3 = new GeoJSON_default();
46470
46611
  var getFeaturesFromWMS = (source, options, abortController) => {