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
package/common/layers/Layer.js
CHANGED
|
@@ -1,140 +1,257 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.setProperties(options.properties);
|
|
9
|
-
this.visible = options.visible === void 0 ? true : !!options.visible;
|
|
10
|
-
this.group = options.group;
|
|
11
|
-
this.copyrights = options.copyrights;
|
|
12
|
-
this.children = options.children;
|
|
13
|
-
this.on(`change:visible:group`, (evt) => {
|
|
14
|
-
if (this.group === evt.target.group && this !== evt.target && this.visible) {
|
|
15
|
-
this.visible = false;
|
|
16
|
-
} else if (this.children) {
|
|
17
|
-
this.children.forEach((child) => child.dispatchEvent(evt));
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
defineProperties(options) {
|
|
22
|
-
const { name, key, properties, hitTolerance } = {
|
|
23
|
-
...options
|
|
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);
|
|
24
8
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
copyrights: {
|
|
40
|
-
get: () => this.get("copyrights"),
|
|
41
|
-
set: (newCopyrights) => {
|
|
42
|
-
const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
|
|
43
|
-
this.set("copyrights", arrValue || []);
|
|
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 __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
44
23
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
var Object_1 = require("ol/Object");
|
|
30
|
+
var uuid_1 = require("uuid");
|
|
31
|
+
var getLayersAsFlatArray_1 = require("../utils/getLayersAsFlatArray");
|
|
32
|
+
/**
|
|
33
|
+
* A class representing a layer to display on map.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const layer = new Layer({
|
|
37
|
+
* name: 'My Layer',
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* @classproperty {string} key - Identifier of the layer. Must be unique.
|
|
41
|
+
* @classproperty {string} name - Name of the layer
|
|
42
|
+
* @classproperty {string[]} copyrights - Array of copyrights.
|
|
43
|
+
* @classproperty {Layer[]} children - List of children layers.
|
|
44
|
+
* @classproperty {boolean} visible - Define if the layer is currently display on the map.
|
|
45
|
+
* @classproperty {boolean} disabled - Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
46
|
+
* @classproperty {number} hitTolerance - Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
47
|
+
* @classproperty {Object} properties - Custom properties.
|
|
48
|
+
* @classproperty {ol/Map~Map|mapboxgl.Map} map - The map where the layer is displayed.
|
|
49
|
+
*/
|
|
50
|
+
var Layer = /** @class */ (function (_super) {
|
|
51
|
+
__extends(Layer, _super);
|
|
52
|
+
/**
|
|
53
|
+
* Constructor
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} options
|
|
56
|
+
* @param {string} [options.key=uuid()] Identifier of the layer. Muste be unique. Default use a generated uuid.
|
|
57
|
+
* @param {string} [options.name] Name of the layer.
|
|
58
|
+
* @param {string[]} [options.copyrights] Array of copyrights.
|
|
59
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers, all child layers will have a parent property associated to this layer.
|
|
60
|
+
* @param {boolean} [options.visible=true] Define if the layer is currently display on the map.
|
|
61
|
+
* @param {boolean} [options.disabled=false] Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
62
|
+
* @param {number} [options.hitTolerance=5] Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
63
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
64
|
+
*/
|
|
65
|
+
function Layer(options) {
|
|
66
|
+
if (options === void 0) { options = {}; }
|
|
67
|
+
var _this = _super.call(this) || this;
|
|
68
|
+
_this.defineProperties(options);
|
|
69
|
+
_this.setProperties(options.properties);
|
|
70
|
+
_this.visible = options.visible === undefined ? true : !!options.visible;
|
|
71
|
+
_this.group = options.group;
|
|
72
|
+
_this.copyrights = options.copyrights;
|
|
73
|
+
_this.children = options.children;
|
|
74
|
+
// Listen for group visiblity change
|
|
75
|
+
// if a layer from a group is newly visible we hide the others.
|
|
76
|
+
_this.on("change:visible:group", function (evt) {
|
|
77
|
+
// We hide layer of the same group
|
|
78
|
+
if (_this.group === evt.target.group &&
|
|
79
|
+
_this !== evt.target &&
|
|
80
|
+
_this.visible) {
|
|
81
|
+
_this.visible = false;
|
|
82
|
+
// Propagate event to parent
|
|
76
83
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.parent.visible = false;
|
|
84
|
+
else if (_this.children) {
|
|
85
|
+
_this.children.forEach(function (child) { return child.dispatchEvent(evt); });
|
|
80
86
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
});
|
|
88
|
+
return _this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Define layer's properties that needs custom get and set.
|
|
92
|
+
*
|
|
93
|
+
* @ignore
|
|
94
|
+
*/
|
|
95
|
+
Layer.prototype.defineProperties = function (options) {
|
|
96
|
+
var _this = this;
|
|
97
|
+
var _a = __assign({}, options), name = _a.name, key = _a.key, properties = _a.properties, hitTolerance = _a.hitTolerance;
|
|
98
|
+
var uid = (0, uuid_1.v4)();
|
|
99
|
+
Object.defineProperties(this, {
|
|
100
|
+
/* Layer's information properties */
|
|
101
|
+
name: {
|
|
102
|
+
value: name,
|
|
103
|
+
},
|
|
104
|
+
key: {
|
|
105
|
+
value: key || uid,
|
|
106
|
+
},
|
|
107
|
+
group: {
|
|
108
|
+
get: function () { return _this.get('group'); },
|
|
109
|
+
set: function (newGroup) {
|
|
110
|
+
_this.set('group', newGroup);
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
copyrights: {
|
|
114
|
+
get: function () { return _this.get('copyrights'); },
|
|
115
|
+
set: function (newCopyrights) {
|
|
116
|
+
var arrValue = newCopyrights && !Array.isArray(newCopyrights)
|
|
117
|
+
? [newCopyrights]
|
|
118
|
+
: newCopyrights;
|
|
119
|
+
_this.set('copyrights', arrValue || []);
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
// options is used for clone function.
|
|
123
|
+
options: {
|
|
124
|
+
value: options,
|
|
125
|
+
},
|
|
126
|
+
map: {
|
|
127
|
+
writable: true,
|
|
128
|
+
},
|
|
129
|
+
/* Layer's state properties */
|
|
130
|
+
visible: {
|
|
131
|
+
get: function () { return _this.get('visible'); },
|
|
132
|
+
set: function (newVisible) {
|
|
133
|
+
if (newVisible === _this.visible) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
_this.set('visible', newVisible);
|
|
137
|
+
if (_this.visible) {
|
|
138
|
+
if (_this.parent && !_this.parent.visible) {
|
|
139
|
+
_this.parent.visible = true;
|
|
140
|
+
}
|
|
141
|
+
if (_this.children && _this.children.find(function (child) { return child.group; })) {
|
|
142
|
+
var child = _this.children.find(function (childd) { return !!childd.group; });
|
|
143
|
+
// Make visible only radioGroup layers
|
|
144
|
+
child.visible = true;
|
|
145
|
+
}
|
|
146
|
+
// Warn the same group that a new layer is visible
|
|
147
|
+
if (_this.parent && _this.group) {
|
|
148
|
+
// We search for the higher parent then it will dispatch to all the tree.
|
|
149
|
+
var higherParent = _this.parent;
|
|
150
|
+
while (higherParent.parent) {
|
|
151
|
+
higherParent = higherParent.parent;
|
|
152
|
+
}
|
|
153
|
+
higherParent.dispatchEvent({
|
|
154
|
+
type: "change:visible:group",
|
|
155
|
+
target: _this,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if (!_this.visible) {
|
|
160
|
+
if (_this.parent &&
|
|
161
|
+
_this.parent.visible &&
|
|
162
|
+
!_this.parent.children.find(function (child) { return child.visible; })) {
|
|
163
|
+
_this.parent.visible = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
disabled: {
|
|
169
|
+
get: function () { return _this.get('disabled'); },
|
|
170
|
+
set: function (newValue) {
|
|
171
|
+
_this.set('disabled', newValue);
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
/* Layer's hierarchy properties */
|
|
175
|
+
parent: {
|
|
176
|
+
value: null,
|
|
177
|
+
writable: true,
|
|
178
|
+
},
|
|
179
|
+
children: {
|
|
180
|
+
get: function () { return _this.get('children') || []; },
|
|
181
|
+
set: function (newValue) {
|
|
182
|
+
(_this.children || []).forEach(function (child) {
|
|
183
|
+
// eslint-disable-next-line no-param-reassign
|
|
184
|
+
child.parent = null;
|
|
185
|
+
});
|
|
186
|
+
if (Array.isArray(newValue)) {
|
|
187
|
+
newValue.forEach(function (child) {
|
|
188
|
+
// eslint-disable-next-line no-param-reassign
|
|
189
|
+
child.parent = _this;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
_this.set('children', newValue || []);
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
/* Layer's query properties */
|
|
196
|
+
hitTolerance: {
|
|
197
|
+
value: hitTolerance || 5,
|
|
198
|
+
writable: true,
|
|
199
|
+
},
|
|
200
|
+
/* Custom app specific properties */
|
|
201
|
+
properties: {
|
|
202
|
+
value: __assign({}, (properties || {})),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Initialize the layer with the map passed in parameters.
|
|
208
|
+
*
|
|
209
|
+
* @param {ol/Map~Map|mapboxgl.Map} map A map.
|
|
210
|
+
*/
|
|
211
|
+
Layer.prototype.attachToMap = function (map) {
|
|
212
|
+
this.detachFromMap();
|
|
213
|
+
/** @ignore */
|
|
214
|
+
this.map = map;
|
|
215
|
+
if (this.children) {
|
|
216
|
+
this.children.forEach(function (child) {
|
|
217
|
+
child.attachToMap(map);
|
|
103
218
|
});
|
|
104
|
-
}
|
|
105
|
-
this.set("children", newValue || []);
|
|
106
219
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
223
|
+
*/
|
|
224
|
+
// eslint-disable-next-line class-methods-use-this
|
|
225
|
+
Layer.prototype.detachFromMap = function () {
|
|
226
|
+
/** @ignore */
|
|
227
|
+
this.map = null;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Request feature information for a given coordinate.
|
|
231
|
+
* This function must be implemented by inheriting layers.
|
|
232
|
+
*
|
|
233
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate.
|
|
234
|
+
* @param {Object} options Some options. See child classes to see which are supported.
|
|
235
|
+
* @return {Promise<FeatureInfo>} An empty response.
|
|
236
|
+
*/
|
|
237
|
+
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-unused-vars
|
|
238
|
+
Layer.prototype.getFeatureInfoAtCoordinate = function (coordinate, options) {
|
|
239
|
+
// eslint-disable-next-line no-console
|
|
240
|
+
console.error('getFeatureInfoAtCoordinate must be implemented by inheriting layers', this.key);
|
|
241
|
+
// This layer returns no feature info.
|
|
242
|
+
// The function is implemented by inheriting layers.
|
|
243
|
+
return Promise.resolve({
|
|
244
|
+
layer: this,
|
|
245
|
+
features: [],
|
|
246
|
+
coordinate: coordinate,
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
251
|
+
*/
|
|
252
|
+
Layer.prototype.flat = function () {
|
|
253
|
+
return (0, getLayersAsFlatArray_1.default)(this);
|
|
254
|
+
};
|
|
255
|
+
return Layer;
|
|
256
|
+
}(Object_1.default));
|
|
257
|
+
exports.default = Layer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright control interface.
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export class CopyrightInterface {
|
|
6
|
+
/**
|
|
7
|
+
* Return an array of layer's copyright.
|
|
8
|
+
*
|
|
9
|
+
* @return {String[]} A list of copyrights to render.
|
|
10
|
+
*/
|
|
11
|
+
getCopyrights(): string[];
|
|
12
|
+
}
|
|
13
|
+
export default CopyrightMixin;
|
|
14
|
+
/**
|
|
15
|
+
* Mixin for CopyrightInterface.
|
|
16
|
+
*
|
|
17
|
+
* @param {Class} Base A class to extend with {CopyrightInterface} functionnalities.
|
|
18
|
+
* @return {Class} A class that implements <CopyrightInterface> class and extends Base;
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
declare function CopyrightMixin(Base: Class): Class;
|
|
22
|
+
//# sourceMappingURL=CopyrightMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyrightMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/CopyrightMixin.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;OAIG;IACH,iBAFY,QAAQ,CAEF;CACnB;;AAED;;;;;;GAMG;AACH,oDAsBG"}
|
|
@@ -1,24 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
/* eslint-disable max-classes-per-file */
|
|
4
|
+
var __extends = (this && this.__extends) || (function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics = Object.setPrototypeOf ||
|
|
7
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
9
|
+
return extendStatics(d, b);
|
|
10
|
+
};
|
|
11
|
+
return function (d, b) {
|
|
12
|
+
if (typeof b !== "function" && b !== null)
|
|
13
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
14
|
+
extendStatics(d, b);
|
|
15
|
+
function __() { this.constructor = d; }
|
|
16
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.CopyrightInterface = void 0;
|
|
21
|
+
/**
|
|
22
|
+
* Copyright control interface.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
var CopyrightInterface = /** @class */ (function () {
|
|
26
|
+
function CopyrightInterface() {
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* Return an array of layer's copyright.
|
|
30
|
+
*
|
|
31
|
+
* @return {String[]} A list of copyrights to render.
|
|
32
|
+
*/
|
|
33
|
+
CopyrightInterface.prototype.getCopyrights = function () { };
|
|
34
|
+
return CopyrightInterface;
|
|
35
|
+
}());
|
|
36
|
+
exports.CopyrightInterface = CopyrightInterface;
|
|
37
|
+
/**
|
|
38
|
+
* Mixin for CopyrightInterface.
|
|
39
|
+
*
|
|
40
|
+
* @param {Class} Base A class to extend with {CopyrightInterface} functionnalities.
|
|
41
|
+
* @return {Class} A class that implements <CopyrightInterface> class and extends Base;
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
var CopyrightMixin = function (Base) {
|
|
45
|
+
return /** @class */ (function (_super) {
|
|
46
|
+
__extends(class_1, _super);
|
|
47
|
+
function class_1() {
|
|
48
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
49
|
+
}
|
|
50
|
+
class_1.prototype.render = function () {
|
|
51
|
+
if (!this.element) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.element.innerHTML = this.active
|
|
55
|
+
? this.getCopyrights().join(' | ')
|
|
56
|
+
: '';
|
|
57
|
+
};
|
|
58
|
+
class_1.prototype.createDefaultElement = function () {
|
|
59
|
+
this.element = document.createElement('div');
|
|
60
|
+
this.element.id = 'mbt-copyright';
|
|
61
|
+
Object.assign(this.element.style, {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
bottom: 0,
|
|
64
|
+
right: 0,
|
|
65
|
+
fontSize: '.8rem',
|
|
66
|
+
padding: '0 10px',
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return class_1;
|
|
70
|
+
}(Base));
|
|
23
71
|
};
|
|
24
|
-
|
|
72
|
+
exports.default = CopyrightMixin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapboxLayerInterface
|
|
3
|
+
*/
|
|
4
|
+
export class MapboxLayerInterface {
|
|
5
|
+
/**
|
|
6
|
+
* Return the render function function for the ol layer.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
getOlLayerRender(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Return the Class to instanciate for the mapbox map.
|
|
12
|
+
*
|
|
13
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
14
|
+
*/
|
|
15
|
+
getMapboxMapClass(): mapboxgl.Map | maplibregl.Map;
|
|
16
|
+
}
|
|
17
|
+
export default MapboxLayerMixin;
|
|
18
|
+
/**
|
|
19
|
+
* Mixin for MapboxLayerLayerInterface.
|
|
20
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs
|
|
21
|
+
*
|
|
22
|
+
* @param {Class} Base A class to extend with {MapboxLayerLayerInterface} functionnalities.
|
|
23
|
+
* @return {Class} A class that implements {MapboxLayerLayerInterface} class and extends Base;
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
declare function MapboxLayerMixin(Base: Class): Class;
|
|
27
|
+
//# sourceMappingURL=MapboxLayerMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapboxLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/MapboxLayerMixin.js"],"names":[],"mappings":"AAOA;;GAEG;AACH;IACE;;;OAGG;IAEH,yBAAqB;IAErB;;;;OAIG;IAEH,qBAHY,eAAa,cAAc,CAGjB;CACvB;;AAED;;;;;;;GAOG;AACH,sDA6MG"}
|