|
1 | | -import { DebouncedFunc } from 'lodash'; |
2 | 1 | import debounce from 'lodash.debounce'; |
3 | | -import { Map, MapEvent } from 'ol'; |
4 | | -import { EventsKey } from 'ol/events'; |
5 | 2 | import { getIntersection, isEmpty } from 'ol/extent'; |
6 | | -import Feature, { FeatureLike } from 'ol/Feature'; |
7 | 3 | import GeoJSON from 'ol/format/GeoJSON'; |
8 | 4 | import Layer from 'ol/layer/Layer'; |
9 | 5 | import VectorLayer from 'ol/layer/Vector'; |
10 | | -import { ObjectEvent } from 'ol/Object'; |
11 | 6 | import { unByKey } from 'ol/Observable'; |
12 | 7 | import { Vector as VectorSource } from 'ol/source'; |
13 | 8 | import Source from 'ol/source/Source'; |
14 | | -import { State } from 'ol/View'; |
15 | | - |
16 | | -import { FilterFunction, SortFunction } from '../../common/typedefs'; |
17 | | -import RealtimeEngine, { |
18 | | - RealtimeEngineOptions, |
19 | | -} from '../../common/utils/RealtimeEngine'; |
20 | | -import { RealtimeAPI } from '../../maplibre'; |
21 | | -import { |
| 9 | + |
| 10 | +import RealtimeEngine from '../../common/utils/RealtimeEngine'; |
| 11 | +import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer'; |
| 12 | +import { fullTrajectoryStyle } from '../styles'; |
| 13 | +import defineDeprecatedProperties from '../utils/defineDeprecatedProperties'; |
| 14 | + |
| 15 | +import type { DebouncedFunc } from 'lodash'; |
| 16 | +import type { Map, MapEvent } from 'ol'; |
| 17 | +import type { EventsKey } from 'ol/events'; |
| 18 | +import type { FeatureLike } from 'ol/Feature'; |
| 19 | +import type Feature from 'ol/Feature'; |
| 20 | +import type { ObjectEvent } from 'ol/Object'; |
| 21 | +import type { State } from 'ol/View'; |
| 22 | + |
| 23 | +import type { FilterFunction, SortFunction } from '../../common/typedefs'; |
| 24 | +import type { RealtimeEngineOptions } from '../../common/utils/RealtimeEngine'; |
| 25 | +import type { RealtimeAPI } from '../../maplibre'; |
| 26 | +import type { |
22 | 27 | RealtimeMode, |
23 | 28 | RealtimeRenderState, |
24 | 29 | RealtimeStopSequence, |
25 | 30 | RealtimeTrainId, |
26 | 31 | ViewState, |
27 | 32 | } from '../../types'; |
28 | | -import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer'; |
29 | | -import { fullTrajectoryStyle } from '../styles'; |
30 | | -import defineDeprecatedProperties from '../utils/defineDeprecatedProperties'; |
31 | | -import { MobilityLayerOptions } from './Layer'; |
| 33 | + |
| 34 | +import type { MobilityLayerOptions } from './Layer'; |
32 | 35 |
|
33 | 36 | const format = new GeoJSON(); |
34 | 37 |
|
@@ -356,8 +359,9 @@ class RealtimeLayer extends Layer { |
356 | 359 | }; |
357 | 360 | } |
358 | 361 |
|
359 | | - highlight(feature: Feature) { |
360 | | - const id = feature?.get('train_id'); |
| 362 | + highlight(features: Feature | Feature[]) { |
| 363 | + const feat = Array.isArray(features) ? features[0] : features; |
| 364 | + const id: null | string | undefined = feat?.get('train_id') as string; |
361 | 365 | if (this.hoverVehicleId !== id) { |
362 | 366 | this.hoverVehicleId = id; |
363 | 367 | this.engine.renderTrajectories(true); |
@@ -437,18 +441,19 @@ class RealtimeLayer extends Layer { |
437 | 441 | } |
438 | 442 |
|
439 | 443 | if (this.selectedVehicleId) { |
440 | | - this.highlightTrajectory(this.selectedVehicleId); |
| 444 | + void this.highlightTrajectory(this.selectedVehicleId); |
441 | 445 | } |
442 | 446 | } |
443 | 447 |
|
444 | | - select(feature: Feature) { |
445 | | - const id = feature?.get('train_id'); |
| 448 | + select(features: Feature | Feature[]) { |
| 449 | + const feat = Array.isArray(features) ? features[0] : features; |
| 450 | + const id: null | string | undefined = feat?.get('train_id') as string; |
446 | 451 | if (this.selectedVehicleId !== id) { |
447 | 452 | this.cleanVectorLayer(); |
448 | 453 | this.selectedVehicleId = id; |
449 | 454 | this.engine.renderTrajectories(true); |
450 | 455 | } |
451 | | - this.highlightTrajectory(id); |
| 456 | + void this.highlightTrajectory(id); |
452 | 457 | } |
453 | 458 |
|
454 | 459 | override setMapInternal(map: Map) { |
|
0 commit comments