mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34
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/api/RealtimeAPI.d.ts +268 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +626 -343
- package/api/RoutingAPI.d.ts +33 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +65 -15
- package/api/StopsAPI.d.ts +36 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +70 -12
- package/api/index.d.ts +5 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +10 -3
- package/api/typedefs.d.ts +105 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/typedefs.js +72 -0
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +82 -30
- package/common/api/WebSocketAPI.d.ts +95 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +313 -168
- package/common/controls/Control.d.ts +74 -0
- package/common/controls/Control.d.ts.map +1 -0
- package/common/controls/Control.js +167 -78
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +18 -2
- package/common/layers/Layer.d.ts +80 -0
- package/common/layers/Layer.d.ts.map +1 -0
- package/common/layers/Layer.js +251 -134
- package/common/mixins/CopyrightMixin.d.ts +22 -0
- package/common/mixins/CopyrightMixin.d.ts.map +1 -0
- package/common/mixins/CopyrightMixin.js +70 -22
- package/common/mixins/MapboxLayerMixin.d.ts +27 -0
- package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
- package/common/mixins/MapboxLayerMixin.js +240 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +698 -429
- package/common/mixins/StopFinderMixin.d.ts +40 -0
- package/common/mixins/StopFinderMixin.d.ts.map +1 -0
- package/common/mixins/StopFinderMixin.js +195 -107
- package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +222 -121
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +24 -4
- package/common/styles/realtimeDefaultStyle.d.ts +15 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +236 -190
- package/common/styles/realtimeDelayStyle.d.ts +11 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +25 -7
- package/common/styles/realtimeSimpleStyle.d.ts +3 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -17
- package/common/typedefs.d.ts +50 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +21 -0
- package/common/utils/cleanStopTime.d.ts +7 -0
- package/common/utils/cleanStopTime.d.ts.map +1 -0
- package/common/utils/cleanStopTime.js +28 -17
- package/common/utils/compareDepartures.d.ts +9 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +34 -22
- package/common/utils/createCanvas.d.ts +9 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -16
- package/common/utils/createTrackerFilters.d.ts +12 -0
- package/common/utils/createTrackerFilters.d.ts.map +1 -0
- package/common/utils/createTrackerFilters.js +75 -54
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -13
- package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +24 -17
- package/common/utils/getMapboxRender.d.ts +5 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +77 -0
- package/common/utils/getMaplibreRender.d.ts +5 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +11 -2
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +20 -10
- package/common/utils/getVehiclePosition.d.ts +14 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +63 -39
- package/common/utils/index.d.ts +12 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +37 -9
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +29 -7
- package/common/utils/renderTrajectories.d.ts +20 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +111 -78
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -17
- package/common/utils/timeUtils.d.ts +5 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +47 -18
- package/common/utils/trackerConfig.d.ts +24 -0
- package/common/utils/trackerConfig.d.ts.map +1 -0
- package/common/utils/trackerConfig.js +171 -118
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +7 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -7
- package/mapbox/controls/CopyrightControl.d.ts +32 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +72 -28
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +6 -1
- package/mapbox/index.d.ts +5 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +20 -4
- package/mapbox/layers/Layer.d.ts +47 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +137 -54
- package/mapbox/layers/RealtimeLayer.d.ts +118 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +310 -183
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +7 -2
- package/mapbox/utils.d.ts +8 -0
- package/mapbox/utils.d.ts.map +1 -0
- package/mapbox/utils.js +54 -29
- package/mbt.js +2052 -2109
- package/mbt.js.map +3 -3
- package/mbt.min.js +18 -18
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +89 -41
- package/ol/controls/RoutingControl.d.ts +180 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +666 -371
- package/ol/controls/StopFinderControl.d.ts +32 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +59 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +9 -3
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +21 -5
- package/ol/layers/Layer.d.ts +49 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +178 -81
- package/ol/layers/MapboxLayer.d.ts +42 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +131 -198
- package/ol/layers/MapboxStyleLayer.d.ts +146 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +382 -186
- package/ol/layers/MaplibreLayer.d.ts +27 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +67 -138
- package/ol/layers/RealtimeLayer.d.ts +119 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +327 -184
- package/ol/layers/RoutingLayer.d.ts +24 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +111 -56
- package/ol/layers/VectorLayer.d.ts +23 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +71 -21
- package/ol/layers/WMSLayer.d.ts +38 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +105 -37
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +19 -8
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
- package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -40
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/ol/styles/index.js +7 -2
- package/package.json +14 -36
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +15 -0
- package/types/index.d.ts +7 -6
- package/types/routing.d.ts +25 -25
- package/types/stops.d.ts +19 -19
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.js +0 -25
- package/api/StopsAPI.test.js +0 -22
- package/common/api/HttpAPI.test.js +0 -50
- package/common/api/WebSocketAPI.test.js +0 -311
- package/common/controls/Control.test.js +0 -87
- package/common/layers/Layer.test.js +0 -134
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.js +0 -182
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.js +0 -165
- package/ol/controls/RoutingControl.test.js +0 -146
- package/ol/controls/StopFinderControl.test.js +0 -48
- package/ol/layers/Layer.test.js +0 -175
- package/ol/layers/MapboxLayer.test.js +0 -160
- package/ol/layers/MapboxStyleLayer.test.js +0 -226
- package/ol/layers/RealtimeLayer.test.js +0 -67
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.js +0 -76
- package/ol/layers/WMSLayer.test.js +0 -57
|
@@ -1,124 +1,225 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
detachFromMap() {
|
|
9
|
-
}
|
|
10
|
-
activateUserInteractions() {
|
|
11
|
-
}
|
|
12
|
-
deactivateUserInteractions() {
|
|
13
|
-
}
|
|
14
|
-
onClick(callback) {
|
|
15
|
-
}
|
|
16
|
-
onHover(callback) {
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const UserInteractionsLayerMixin = (Base) => class extends Base {
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
super(options);
|
|
22
|
-
const {
|
|
23
|
-
userInteractions = true,
|
|
24
|
-
userClickInteractions = true,
|
|
25
|
-
userHoverInteractions = true,
|
|
26
|
-
defaultUserInteractions = true
|
|
27
|
-
} = options;
|
|
28
|
-
this.userInteractions = userInteractions;
|
|
29
|
-
this.userClickInteractions = userClickInteractions;
|
|
30
|
-
this.userHoverInteractions = userHoverInteractions;
|
|
31
|
-
this.defaultUserInteractions = defaultUserInteractions;
|
|
32
|
-
this.userClickCallbacks = [];
|
|
33
|
-
this.userHoverCallbacks = [];
|
|
34
|
-
this.userClickEventsKeys = [];
|
|
35
|
-
this.userHoverEventsKeys = [];
|
|
36
|
-
this.onUserClickCallback = this.onUserClickCallback.bind(this);
|
|
37
|
-
this.onUserMoveCallback = this.onUserMoveCallback.bind(this);
|
|
38
|
-
const { onClick, onHover } = options;
|
|
39
|
-
if (this.userInteractions && this.userClickInteractions && onClick) {
|
|
40
|
-
this.onClick(onClick);
|
|
41
|
-
}
|
|
42
|
-
if (this.userInteractions && this.userHoverInteractions && onHover) {
|
|
43
|
-
this.onHover(onHover);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
attachToMap(map, options) {
|
|
47
|
-
super.attachToMap(map, options);
|
|
48
|
-
if (this.userInteractions && this.defaultUserInteractions && this.userClickInteractions && this.onFeatureClick) {
|
|
49
|
-
this.onClick(this.onFeatureClick);
|
|
50
|
-
}
|
|
51
|
-
if (this.userInteractions && this.defaultUserInteractions && this.userHoverInteractions && this.onFeatureHover) {
|
|
52
|
-
this.onHover(this.onFeatureHover);
|
|
53
|
-
}
|
|
54
|
-
this.listenEvents();
|
|
55
|
-
}
|
|
56
|
-
detachFromMap() {
|
|
57
|
-
this.unlistenEvents();
|
|
58
|
-
super.detachFromMap();
|
|
59
|
-
}
|
|
60
|
-
listenEvents() {
|
|
61
|
-
this.unlistenEvents();
|
|
62
|
-
this.userClickCallbacks.forEach((callback) => {
|
|
63
|
-
this.userClickEventsKeys.push(this.on("user:click", ({ target: { features, layer, coordinate } }) => {
|
|
64
|
-
callback(features, layer, coordinate);
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
this.userHoverCallbacks.forEach((callback) => {
|
|
68
|
-
this.userHoverEventsKeys.push([
|
|
69
|
-
this.on("user:hover", ({ target: { features, layer, coordinate, event } }) => {
|
|
70
|
-
callback(features, layer, coordinate, event);
|
|
71
|
-
})
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
unlistenEvents() {
|
|
76
|
-
unByKey(this.userClickEventsKeys);
|
|
77
|
-
unByKey(this.userHoverEventsKeys);
|
|
78
|
-
this.userClickEventsKeys = [];
|
|
79
|
-
this.userHoverEventsKeys = [];
|
|
80
|
-
}
|
|
81
|
-
onClick(callback) {
|
|
82
|
-
this.userClickCallbacks.push(callback);
|
|
83
|
-
this.activateUserInteractions();
|
|
84
|
-
}
|
|
85
|
-
onHover(callback) {
|
|
86
|
-
this.userHoverCallbacks.push(callback);
|
|
87
|
-
this.activateUserInteractions();
|
|
88
|
-
}
|
|
89
|
-
onUserClickCallback(evt) {
|
|
90
|
-
const emptyFeatureInfo = {
|
|
91
|
-
features: [],
|
|
92
|
-
layer: this,
|
|
93
|
-
coordinate: evt.coordinate || fromLonLat(evt.lngLat.toArray()),
|
|
94
|
-
event: evt
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
95
8
|
};
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}).catch(() => emptyFeatureInfo);
|
|
103
|
-
}
|
|
104
|
-
onUserMoveCallback(evt) {
|
|
105
|
-
const emptyFeatureInfo = {
|
|
106
|
-
features: [],
|
|
107
|
-
layer: this,
|
|
108
|
-
coordinate: evt.coordinate || fromLonLat(evt.lngLat.toArray()),
|
|
109
|
-
event: evt
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
110
15
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.UserInteractionsLayerInterface = void 0;
|
|
19
|
+
/* eslint-disable no-empty-function,@typescript-eslint/no-empty-function */
|
|
20
|
+
/* eslint-disable no-useless-constructor,@typescript-eslint/no-useless-constructor */
|
|
21
|
+
/* eslint-disable no-unused-vars,@typescript-eslint/no-unused-vars */
|
|
22
|
+
/* eslint-disable class-methods-use-this */
|
|
23
|
+
/* eslint-disable max-classes-per-file */
|
|
24
|
+
var proj_1 = require("ol/proj");
|
|
25
|
+
var Observable_1 = require("ol/Observable");
|
|
26
|
+
/**
|
|
27
|
+
* UserInteractionsLayerInterface.
|
|
28
|
+
*/
|
|
29
|
+
var UserInteractionsLayerInterface = /** @class */ (function () {
|
|
30
|
+
/*
|
|
31
|
+
* Constructor
|
|
32
|
+
|
|
33
|
+
* @param {Object} options Layer options.
|
|
34
|
+
* @param {string} options.userInteractions If true, it listens for user mouse hover and click event.
|
|
35
|
+
* @param {string} options.userClickInteractions If true, it listens for user click event.
|
|
36
|
+
* @param {string} options.userHoverInteractions If true, it listens for user mouse over event.
|
|
37
|
+
* @param {string} options.defaultUserInteractions If true, it adds default listeners for user mouse hover and click event.
|
|
38
|
+
*/
|
|
39
|
+
function UserInteractionsLayerInterface(options) {
|
|
40
|
+
if (options === void 0) { options = {}; }
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Initialize the layer adding user interactions.
|
|
44
|
+
*
|
|
45
|
+
* @param {ol/Map~Map} map
|
|
46
|
+
*/
|
|
47
|
+
UserInteractionsLayerInterface.prototype.attachToMap = function (map) { };
|
|
48
|
+
/**
|
|
49
|
+
* Terminate the layer unsubscribing user interactions.
|
|
50
|
+
*/
|
|
51
|
+
UserInteractionsLayerInterface.prototype.detachFromMap = function () { };
|
|
52
|
+
/**
|
|
53
|
+
* Activate map listeners events.
|
|
54
|
+
*/
|
|
55
|
+
UserInteractionsLayerInterface.prototype.activateUserInteractions = function () { };
|
|
56
|
+
/**
|
|
57
|
+
* Deactivaet map listeners events.
|
|
58
|
+
*/
|
|
59
|
+
UserInteractionsLayerInterface.prototype.deactivateUserInteractions = function () { };
|
|
60
|
+
/**
|
|
61
|
+
* Terminate the layer unsubscribing user interactions.
|
|
62
|
+
*/
|
|
63
|
+
UserInteractionsLayerInterface.prototype.onClick = function (callback) { };
|
|
64
|
+
/**
|
|
65
|
+
* Terminate the layer unsubscribing user interactions.
|
|
66
|
+
*/
|
|
67
|
+
UserInteractionsLayerInterface.prototype.onHover = function (callback) { };
|
|
68
|
+
return UserInteractionsLayerInterface;
|
|
69
|
+
}());
|
|
70
|
+
exports.UserInteractionsLayerInterface = UserInteractionsLayerInterface;
|
|
71
|
+
/**
|
|
72
|
+
* Mixin for UserInteractionsLayerInterface. It provide onClick and onHover functions.
|
|
73
|
+
*
|
|
74
|
+
* @param {Class} Base A class to extend with {UserInteractionsLayerInterface} functionnalities.
|
|
75
|
+
* @return {Class} A class that implements {UserInteractionsLayerInterface} class and extends Base;
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
var UserInteractionsLayerMixin = function (Base) {
|
|
79
|
+
return /** @class */ (function (_super) {
|
|
80
|
+
__extends(class_1, _super);
|
|
81
|
+
function class_1(options) {
|
|
82
|
+
if (options === void 0) { options = {}; }
|
|
83
|
+
var _this = _super.call(this, options) || this;
|
|
84
|
+
var _a = options.userInteractions, userInteractions = _a === void 0 ? true : _a, _b = options.userClickInteractions, userClickInteractions = _b === void 0 ? true : _b, _c = options.userHoverInteractions, userHoverInteractions = _c === void 0 ? true : _c, _d = options.defaultUserInteractions, defaultUserInteractions = _d === void 0 ? true : _d;
|
|
85
|
+
_this.userInteractions = userInteractions;
|
|
86
|
+
_this.userClickInteractions = userClickInteractions;
|
|
87
|
+
_this.userHoverInteractions = userHoverInteractions;
|
|
88
|
+
_this.defaultUserInteractions = defaultUserInteractions;
|
|
89
|
+
_this.userClickCallbacks = [];
|
|
90
|
+
_this.userHoverCallbacks = [];
|
|
91
|
+
_this.userClickEventsKeys = [];
|
|
92
|
+
_this.userHoverEventsKeys = [];
|
|
93
|
+
_this.onUserClickCallback = _this.onUserClickCallback.bind(_this);
|
|
94
|
+
_this.onUserMoveCallback = _this.onUserMoveCallback.bind(_this);
|
|
95
|
+
// Add mouse event callbacks
|
|
96
|
+
var onClick = options.onClick, onHover = options.onHover;
|
|
97
|
+
if (_this.userInteractions && _this.userClickInteractions && onClick) {
|
|
98
|
+
_this.onClick(onClick);
|
|
99
|
+
}
|
|
100
|
+
if (_this.userInteractions && _this.userHoverInteractions && onHover) {
|
|
101
|
+
_this.onHover(onHover);
|
|
102
|
+
}
|
|
103
|
+
return _this;
|
|
104
|
+
}
|
|
105
|
+
class_1.prototype.attachToMap = function (map, options) {
|
|
106
|
+
_super.prototype.attachToMap.call(this, map, options);
|
|
107
|
+
if (this.userInteractions &&
|
|
108
|
+
this.defaultUserInteractions &&
|
|
109
|
+
this.userClickInteractions &&
|
|
110
|
+
this.onFeatureClick) {
|
|
111
|
+
this.onClick(this.onFeatureClick);
|
|
112
|
+
}
|
|
113
|
+
if (this.userInteractions &&
|
|
114
|
+
this.defaultUserInteractions &&
|
|
115
|
+
this.userHoverInteractions &&
|
|
116
|
+
this.onFeatureHover) {
|
|
117
|
+
this.onHover(this.onFeatureHover);
|
|
118
|
+
}
|
|
119
|
+
this.listenEvents();
|
|
120
|
+
};
|
|
121
|
+
class_1.prototype.detachFromMap = function () {
|
|
122
|
+
this.unlistenEvents();
|
|
123
|
+
_super.prototype.detachFromMap.call(this);
|
|
124
|
+
};
|
|
125
|
+
class_1.prototype.listenEvents = function () {
|
|
126
|
+
var _this = this;
|
|
127
|
+
this.unlistenEvents();
|
|
128
|
+
this.userClickCallbacks.forEach(function (callback) {
|
|
129
|
+
_this.userClickEventsKeys.push(_this.on('user:click', function (_a) {
|
|
130
|
+
var _b = _a.target, features = _b.features, layer = _b.layer, coordinate = _b.coordinate;
|
|
131
|
+
callback(features, layer, coordinate);
|
|
132
|
+
}));
|
|
133
|
+
});
|
|
134
|
+
this.userHoverCallbacks.forEach(function (callback) {
|
|
135
|
+
_this.userHoverEventsKeys.push(_this.on('user:hover', function (_a) {
|
|
136
|
+
var _b = _a.target, features = _b.features, layer = _b.layer, coordinate = _b.coordinate, event = _b.event;
|
|
137
|
+
callback(features, layer, coordinate, event);
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
class_1.prototype.unlistenEvents = function () {
|
|
142
|
+
(0, Observable_1.unByKey)(this.userClickEventsKeys);
|
|
143
|
+
(0, Observable_1.unByKey)(this.userHoverEventsKeys);
|
|
144
|
+
this.userClickEventsKeys = [];
|
|
145
|
+
this.userHoverEventsKeys = [];
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Listens to click events on the layer.
|
|
149
|
+
* @param {function} callback Callback function, called with the clicked
|
|
150
|
+
* features,
|
|
151
|
+
* the layer instance and the click event.
|
|
152
|
+
*/
|
|
153
|
+
class_1.prototype.onClick = function (callback) {
|
|
154
|
+
this.userClickCallbacks.push(callback);
|
|
155
|
+
this.activateUserInteractions();
|
|
156
|
+
if (this.map) {
|
|
157
|
+
// If the layer is already attached to the map we reload the events
|
|
158
|
+
this.listenEvents();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Listens to hover events on the layer.
|
|
163
|
+
* @param {function} callback Callback function, called with the clicked
|
|
164
|
+
* features, the layer instance and the click event.
|
|
165
|
+
*/
|
|
166
|
+
class_1.prototype.onHover = function (callback) {
|
|
167
|
+
this.userHoverCallbacks.push(callback);
|
|
168
|
+
this.activateUserInteractions();
|
|
169
|
+
if (this.map) {
|
|
170
|
+
// If the layer is already attached to the map we reload the events
|
|
171
|
+
this.listenEvents();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Function triggered when the user click the map.
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
class_1.prototype.onUserClickCallback = function (evt) {
|
|
179
|
+
var _this = this;
|
|
180
|
+
var coordinate = evt.coordinate || (0, proj_1.fromLonLat)(evt.lngLat.toArray());
|
|
181
|
+
var emptyFeatureInfo = {
|
|
182
|
+
features: [],
|
|
183
|
+
layer: this,
|
|
184
|
+
coordinate: coordinate,
|
|
185
|
+
event: evt,
|
|
186
|
+
};
|
|
187
|
+
return this.getFeatureInfoAtCoordinate(coordinate)
|
|
188
|
+
.then(function (featureInfo) {
|
|
189
|
+
_this.dispatchEvent({
|
|
190
|
+
type: 'user:click',
|
|
191
|
+
target: featureInfo,
|
|
192
|
+
});
|
|
193
|
+
return featureInfo;
|
|
194
|
+
})
|
|
195
|
+
.catch(function () { return emptyFeatureInfo; });
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Function triggered when the user move the cursor.
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
class_1.prototype.onUserMoveCallback = function (evt) {
|
|
202
|
+
var _this = this;
|
|
203
|
+
var coordinate = evt.coordinate || (0, proj_1.fromLonLat)(evt.lngLat.toArray());
|
|
204
|
+
var emptyFeatureInfo = {
|
|
205
|
+
features: [],
|
|
206
|
+
layer: this,
|
|
207
|
+
coordinate: coordinate,
|
|
208
|
+
event: evt,
|
|
209
|
+
};
|
|
210
|
+
return this.getFeatureInfoAtCoordinate(coordinate)
|
|
211
|
+
.then(function (featureInfo) {
|
|
212
|
+
_this.dispatchEvent({
|
|
213
|
+
type: 'user:hover',
|
|
214
|
+
target: featureInfo,
|
|
215
|
+
});
|
|
216
|
+
return featureInfo;
|
|
217
|
+
})
|
|
218
|
+
.catch(function () { return emptyFeatureInfo; });
|
|
219
|
+
};
|
|
220
|
+
class_1.prototype.activateUserInteractions = function () { };
|
|
221
|
+
class_1.prototype.deactivateUserInteractions = function () { };
|
|
222
|
+
return class_1;
|
|
223
|
+
}(Base));
|
|
123
224
|
};
|
|
124
|
-
|
|
225
|
+
exports.default = UserInteractionsLayerMixin;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
|
|
2
|
+
export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
|
|
3
|
+
export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
|
|
4
|
+
export * from "./realtimeDefaultStyle";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/styles/index.js"],"names":[],"mappings":""}
|
package/common/styles/index.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.realtimeSimpleStyle = exports.realtimeDelayStyle = exports.realtimeDefaultStyle = void 0;
|
|
18
|
+
var realtimeDefaultStyle_1 = require("./realtimeDefaultStyle");
|
|
19
|
+
Object.defineProperty(exports, "realtimeDefaultStyle", { enumerable: true, get: function () { return realtimeDefaultStyle_1.default; } });
|
|
20
|
+
var realtimeDelayStyle_1 = require("./realtimeDelayStyle");
|
|
21
|
+
Object.defineProperty(exports, "realtimeDelayStyle", { enumerable: true, get: function () { return realtimeDelayStyle_1.default; } });
|
|
22
|
+
var realtimeSimpleStyle_1 = require("./realtimeSimpleStyle");
|
|
23
|
+
Object.defineProperty(exports, "realtimeSimpleStyle", { enumerable: true, get: function () { return realtimeSimpleStyle_1.default; } });
|
|
24
|
+
__exportStar(require("./realtimeDefaultStyle"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getDelayBgCanvas(origin: any, radius: any, color: any): any;
|
|
2
|
+
export function getDelayTextCanvas(width: any, text: any, fontSize: any, font: any, delayColor: any, delayOutlineColor?: string, pixelRatio?: number): any;
|
|
3
|
+
export function getCircleCanvas(origin: any, radius: any, color: any, hasStroke: any, hasDash: any, pixelRatio: any): any;
|
|
4
|
+
export function getTextCanvas(text: any, origin: any, textSize: any, fillColor: any, strokeColor: any, hasStroke: any, pixelRatio: any): any;
|
|
5
|
+
export default realtimeDefaultStyle;
|
|
6
|
+
/**
|
|
7
|
+
* A tracker style that take in account the delay.
|
|
8
|
+
*
|
|
9
|
+
* @param {*} trajectory The trajectory to render.
|
|
10
|
+
* @param {*} viewState The view state of the map.
|
|
11
|
+
* @param {*} options Some options to change the rendering
|
|
12
|
+
* @return a canvas
|
|
13
|
+
*/
|
|
14
|
+
declare function realtimeDefaultStyle(trajectory: any, viewState: any, options: any): any;
|
|
15
|
+
//# sourceMappingURL=realtimeDefaultStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeDefaultStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeDefaultStyle.js"],"names":[],"mappings":"AAUO,4EAeN;AAUM,2JA2BN;AAUM,0HAoCN;AAUM,6IAuCN;;AAKD;;;;;;;GAOG;AACH,0FAgMC"}
|