mobility-toolbox-js 3.0.0-beta.14 → 3.0.0-beta.16

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") {
@@ -44276,35 +44485,62 @@ uniform ${i3} ${s3} u_${a3};
44276
44485
  })
44277
44486
  );
44278
44487
  this.options = options;
44279
- this.children = options.children || [];
44488
+ this.set("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
@@ -44355,7 +44613,7 @@ uniform ${i3} ${s3} u_${a3};
44355
44613
  (oldValue || []).forEach((child) => {
44356
44614
  child.set("parent", void 0);
44357
44615
  });
44358
- (this.children || []).forEach((child) => {
44616
+ (this.get("children") || []).forEach((child) => {
44359
44617
  child.set("parent", this);
44360
44618
  });
44361
44619
  }
@@ -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,29 @@ 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 buildStyleUrl = (url, style, apiKey, apiKeyName) => {
44668
+ return getUrlWithParams_default(`${url}/styles/${style}/style.json`, {
44669
+ [apiKeyName]: apiKey
44670
+ }).toString();
44671
+ };
44672
+ var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(MapLibreLayer) {
44509
44673
  get mbMap() {
44510
- console.warn("Deprecated. Use layer.maplibreMap.");
44674
+ console.warn(".mbMap deprecated. Use layer.maplibreMap.");
44511
44675
  return this.maplibreMap;
44512
44676
  }
44513
- get queryRenderedFeaturesOptions() {
44514
- return this.get("queryRenderedFeaturesOptions");
44515
- }
44516
- set queryRenderedFeaturesOptions(newValue) {
44517
- this.set("queryRenderedFeaturesOptions", newValue);
44677
+ get maplibreMap() {
44678
+ console.warn(".maplibreMap eprecated. Use layer.mapLibreMap.");
44679
+ return this.mapLibreMap;
44518
44680
  }
44681
+ // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
44682
+ // return this.get('queryRenderedFeaturesOptions');
44683
+ // }
44684
+ // set queryRenderedFeaturesOptions(
44685
+ // newValue: maplibregl.QueryRenderedFeaturesOptions,
44686
+ // ) {
44687
+ // this.set('queryRenderedFeaturesOptions', newValue);
44688
+ // }
44519
44689
  get style() {
44520
44690
  return this.get("style");
44521
44691
  }
@@ -44534,32 +44704,29 @@ uniform ${i3} ${s3} u_${a3};
44534
44704
  * @param {MaplibreLayerOptions} options
44535
44705
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
44536
44706
  * @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.
44707
+ * @param {maplibregl.MapOptions} [options.mapLibreOptions={ interactive: false, trackResize: false, attributionControl: false }] Maplibre map options.
44538
44708
  * @param {string} [options.style="travic_v2"] The geOps Maps API style.
44539
44709
  * @param {string} [options.url="https://maps.geops.io"] The geOps Maps API url.
44540
44710
  */
44541
44711
  constructor(options) {
44542
- super({
44543
- source: new Source_default({
44544
- attributions: () => {
44545
- return this.maplibreMap && getMapGlCopyrights_default(this.maplibreMap) || [];
44546
- }
44547
- }),
44712
+ const newOptions = {
44548
44713
  apiKeyName: "key",
44549
44714
  style: "travic_v2",
44550
44715
  url: "https://maps.geops.io",
44551
44716
  ...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 || {}
44717
+ mapLibreOptions: {
44718
+ ...options.mapLibreOptions || {}
44561
44719
  }
44562
- });
44720
+ };
44721
+ if (!newOptions.mapLibreOptions.style && newOptions.apiKey) {
44722
+ newOptions.mapLibreOptions.style = buildStyleUrl(
44723
+ newOptions.url,
44724
+ newOptions.style,
44725
+ newOptions.apiKey,
44726
+ newOptions.apiKeyName
44727
+ );
44728
+ }
44729
+ super(newOptions);
44563
44730
  }
44564
44731
  /**
44565
44732
  * Initialize the layer and listen to feature clicks.
@@ -44567,69 +44734,19 @@ uniform ${i3} ${s3} u_${a3};
44567
44734
  */
44568
44735
  attachToMap(map) {
44569
44736
  super.attachToMap(map);
44570
- this.loadMbMap();
44571
- const updateMaplibreMapDebounced = (0, import_lodash.default)(
44737
+ this.updateMaplibreMap();
44738
+ const updateMaplibreMapDebounced = (0, import_lodash2.default)(
44572
44739
  this.updateMaplibreMap.bind(this),
44573
44740
  150
44574
44741
  );
44575
- this.olListenersKeys.push(
44742
+ this.olEventsKeys.push(
44576
44743
  this.on("propertychange", (evt) => {
44577
- if (/(apiKey|apiKeyName|url|style)/.test(evt.key)) {
44744
+ if (/(url|style)/.test(evt.key)) {
44578
44745
  updateMaplibreMapDebounced();
44579
44746
  }
44580
44747
  })
44581
44748
  );
44582
44749
  }
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
44750
  getStyle() {
44634
44751
  if (this.style && typeof this.style === "object" && this.style.name && this.style.version) {
44635
44752
  return this.style;
@@ -44637,19 +44754,15 @@ uniform ${i3} ${s3} u_${a3};
44637
44754
  if (this.url.includes("style.json")) {
44638
44755
  return this.url;
44639
44756
  }
44640
- return getUrlWithParams_default(`${this.url}/styles/${this.style}/style.json`, {
44641
- [this.apiKeyName]: this.apiKey
44642
- }).toString();
44643
- }
44644
- // 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);
44757
+ return buildStyleUrl(
44758
+ this.url,
44759
+ this.style,
44760
+ this.get("apiKey"),
44761
+ this.get("apiKeyName")
44762
+ );
44650
44763
  }
44651
44764
  updateMaplibreMap() {
44652
- this.maplibreMap?.setStyle(this.getStyle(), { diff: false });
44765
+ this.mapLibreMap?.setStyle(this.getStyle(), { diff: false });
44653
44766
  }
44654
44767
  /**
44655
44768
  * Create a copy of the MaplibreLayer.
@@ -44757,7 +44870,9 @@ uniform ${i3} ${s3} u_${a3};
44757
44870
  * @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
44758
44871
  * @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
44759
44872
  */
44760
- constructor(options = {}) {
44873
+ constructor(options = {
44874
+ mapLibreOptions: { style: { version: 8, sources: {}, layers: [] } }
44875
+ }) {
44761
44876
  if (options.mapboxLayer) {
44762
44877
  console.warn(
44763
44878
  "options.mapboxLayer is deprecated. Use options.maplibreLayer instead."
@@ -44860,7 +44975,7 @@ uniform ${i3} ${s3} u_${a3};
44860
44975
  return;
44861
44976
  }
44862
44977
  if (!this.map.getTargetElement()) {
44863
- this.olListenersKeys.push(
44978
+ this.olEventsKeys.push(
44864
44979
  this.map.on("change:target", () => {
44865
44980
  this.attachToMap(map);
44866
44981
  })
@@ -44875,7 +44990,7 @@ uniform ${i3} ${s3} u_${a3};
44875
44990
  maplibreMap.once("load", this.onLoad);
44876
44991
  }
44877
44992
  }
44878
- this.olListenersKeys.push(
44993
+ this.olEventsKeys.push(
44879
44994
  // @ts-expect-error 'load' is a custom event
44880
44995
  this.maplibreLayer.on("load", this.onLoad.bind(this)),
44881
44996
  this.on("change:visible", (evt) => {
@@ -45138,11 +45253,11 @@ uniform ${i3} ${s3} u_${a3};
45138
45253
  var MaplibreStyleLayer_default = MaplibreStyleLayer;
45139
45254
 
45140
45255
  // src/ol/layers/RealtimeLayer.ts
45141
- var import_lodash4 = __toESM(require_lodash());
45256
+ var import_lodash5 = __toESM(require_lodash());
45142
45257
 
45143
45258
  // src/common/mixins/RealtimeLayerMixin.ts
45144
- var import_lodash2 = __toESM(require_lodash());
45145
- var import_lodash3 = __toESM(require_lodash2());
45259
+ var import_lodash3 = __toESM(require_lodash());
45260
+ var import_lodash4 = __toESM(require_lodash2());
45146
45261
  function RealtimeLayerMixin(Base) {
45147
45262
  return class Mixin extends Base {
45148
45263
  constructor(options) {
@@ -45221,12 +45336,12 @@ uniform ${i3} ${s3} u_${a3};
45221
45336
  return this.renderTimeIntervalByZoom[zoom];
45222
45337
  };
45223
45338
  this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
45224
- this.throttleRenderTrajectories = (0, import_lodash3.default)(
45339
+ this.throttleRenderTrajectories = (0, import_lodash4.default)(
45225
45340
  this.renderTrajectoriesInternal,
45226
45341
  50,
45227
45342
  { leading: false, trailing: true }
45228
45343
  );
45229
- this.debounceRenderTrajectories = (0, import_lodash2.default)(
45344
+ this.debounceRenderTrajectories = (0, import_lodash3.default)(
45230
45345
  this.renderTrajectoriesInternal,
45231
45346
  50,
45232
45347
  { leading: true, trailing: true, maxWait: 5e3 }
@@ -45636,13 +45751,13 @@ uniform ${i3} ${s3} u_${a3};
45636
45751
  const nextTick = Math.max(25, timeStep / (this.speed || 1));
45637
45752
  const nextThrottleTick = Math.min(nextTick, 500);
45638
45753
  if (this.useThrottle) {
45639
- this.throttleRenderTrajectories = (0, import_lodash3.default)(
45754
+ this.throttleRenderTrajectories = (0, import_lodash4.default)(
45640
45755
  this.renderTrajectoriesInternal,
45641
45756
  nextThrottleTick,
45642
45757
  { leading: true, trailing: true }
45643
45758
  );
45644
45759
  } else if (this.useDebounce) {
45645
- this.debounceRenderTrajectories = (0, import_lodash2.default)(
45760
+ this.debounceRenderTrajectories = (0, import_lodash3.default)(
45646
45761
  this.renderTrajectoriesInternal,
45647
45762
  nextThrottleTick,
45648
45763
  { leading: true, trailing: true, maxWait: 5e3 }
@@ -46205,8 +46320,8 @@ uniform ${i3} ${s3} u_${a3};
46205
46320
  zoom: void 0,
46206
46321
  rotation: 0
46207
46322
  };
46208
- this.onZoomEndDebounced = (0, import_lodash4.default)(this.onZoomEnd, 100);
46209
- this.onMoveEndDebounced = (0, import_lodash4.default)(this.onMoveEnd, 100);
46323
+ this.onZoomEndDebounced = (0, import_lodash5.default)(this.onZoomEnd, 100);
46324
+ this.onMoveEndDebounced = (0, import_lodash5.default)(this.onMoveEnd, 100);
46210
46325
  }
46211
46326
  /**
46212
46327
  * @private
@@ -46223,7 +46338,7 @@ uniform ${i3} ${s3} u_${a3};
46223
46338
  }
46224
46339
  const index = this.map.getLayers().getArray().indexOf(this);
46225
46340
  this.map.getLayers().insertAt(index, this.vectorLayer);
46226
- this.olListenersKeys.push(
46341
+ this.olEventsKeys.push(
46227
46342
  ...this.map.on(
46228
46343
  ["moveend", "change:target"],
46229
46344
  // @ts-expect-error - bad ol definitions
@@ -46472,6 +46587,35 @@ uniform ${i3} ${s3} u_${a3};
46472
46587
  };
46473
46588
  var Layer_default4 = Layer2;
46474
46589
 
46590
+ // src/ol/layers/VectorLayer.ts
46591
+ var VectorLayer2 = class _VectorLayer extends Layer_default4 {
46592
+ /**
46593
+ * @deprecated
46594
+ */
46595
+ getFeatureInfoAtCoordinate(coordinate) {
46596
+ let features = [];
46597
+ if (this.map) {
46598
+ const pixel = this.map.getPixelFromCoordinate(coordinate);
46599
+ features = this.map.getFeaturesAtPixel(pixel, {
46600
+ layerFilter: (l) => l === this.olLayer,
46601
+ hitTolerance: this.hitTolerance || 5
46602
+ });
46603
+ }
46604
+ return Promise.resolve({
46605
+ features,
46606
+ layer: this,
46607
+ coordinate
46608
+ });
46609
+ }
46610
+ /**
46611
+ * @deprecated
46612
+ */
46613
+ clone(newOptions) {
46614
+ return new _VectorLayer({ ...this.options, ...newOptions });
46615
+ }
46616
+ };
46617
+ var VectorLayer_default2 = VectorLayer2;
46618
+
46475
46619
  // src/ol/utils/getFeatureInfoAtCoordinate.ts
46476
46620
  var format3 = new GeoJSON_default();
46477
46621
  var getFeaturesFromWMS = (source, options, abortController) => {