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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default StopFinderControl;
|
|
2
|
+
/**
|
|
3
|
+
* Search stations.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { Map } from 'ol';
|
|
7
|
+
* import { StopFinderControl } from 'mobility-toolbox-js/ol';
|
|
8
|
+
*
|
|
9
|
+
* const map = new Map({
|
|
10
|
+
* target: 'map',
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* const control = new StopFinderControl({
|
|
14
|
+
* apiKey: [yourApiKey]
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* control.attachToMap(map);
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
21
|
+
*
|
|
22
|
+
* @extends {Control}
|
|
23
|
+
* @implements {StopFinderInterface}
|
|
24
|
+
*/
|
|
25
|
+
declare class StopFinderControl extends Control implements StopFinderInterface {
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
private onSuggestionClick;
|
|
30
|
+
}
|
|
31
|
+
import Control from "../../common/controls/Control";
|
|
32
|
+
//# sourceMappingURL=StopFinderControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopFinderControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/StopFinderControl.js"],"names":[],"mappings":";AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,2DAFgB,mBAAmB;IAGjC;;OAEG;IACH,0BAGC;CACF"}
|
|
@@ -1,10 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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);
|
|
8
|
+
};
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var proj_1 = require("ol/proj");
|
|
19
|
+
var Control_1 = require("../../common/controls/Control");
|
|
20
|
+
var StopFinderMixin_1 = require("../../common/mixins/StopFinderMixin");
|
|
21
|
+
/**
|
|
22
|
+
* Search stations.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* import { Map } from 'ol';
|
|
26
|
+
* import { StopFinderControl } from 'mobility-toolbox-js/ol';
|
|
27
|
+
*
|
|
28
|
+
* const map = new Map({
|
|
29
|
+
* target: 'map',
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* const control = new StopFinderControl({
|
|
33
|
+
* apiKey: [yourApiKey]
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* control.attachToMap(map);
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
40
|
+
*
|
|
41
|
+
* @extends {Control}
|
|
42
|
+
* @implements {StopFinderInterface}
|
|
43
|
+
*/
|
|
44
|
+
var StopFinderControl = /** @class */ (function (_super) {
|
|
45
|
+
__extends(StopFinderControl, _super);
|
|
46
|
+
function StopFinderControl() {
|
|
47
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
StopFinderControl.prototype.onSuggestionClick = function (_a) {
|
|
53
|
+
var geometry = _a.geometry;
|
|
54
|
+
var coord = (0, proj_1.fromLonLat)(geometry.coordinates);
|
|
55
|
+
this.map.getView().setCenter(coord);
|
|
56
|
+
};
|
|
57
|
+
return StopFinderControl;
|
|
58
|
+
}((0, StopFinderMixin_1.default)(Control_1.default)));
|
|
59
|
+
exports.default = StopFinderControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/index.js"],"names":[],"mappings":""}
|
package/ol/controls/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StopFinderControl = exports.RoutingControl = exports.CopyrightControl = void 0;
|
|
4
|
+
var CopyrightControl_1 = require("./CopyrightControl");
|
|
5
|
+
Object.defineProperty(exports, "CopyrightControl", { enumerable: true, get: function () { return CopyrightControl_1.default; } });
|
|
6
|
+
var RoutingControl_1 = require("./RoutingControl");
|
|
7
|
+
Object.defineProperty(exports, "RoutingControl", { enumerable: true, get: function () { return RoutingControl_1.default; } });
|
|
8
|
+
var StopFinderControl_1 = require("./StopFinderControl");
|
|
9
|
+
Object.defineProperty(exports, "StopFinderControl", { enumerable: true, get: function () { return StopFinderControl_1.default; } });
|
package/ol/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ol/index.js"],"names":[],"mappings":""}
|
package/ol/index.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
__exportStar(require("../api"), exports);
|
|
18
|
+
__exportStar(require("../common"), exports);
|
|
19
|
+
__exportStar(require("./controls"), exports);
|
|
20
|
+
__exportStar(require("./layers"), exports);
|
|
21
|
+
__exportStar(require("./styles"), exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default Layer;
|
|
2
|
+
/**
|
|
3
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
7
|
+
*
|
|
8
|
+
* const layer = new Layer({
|
|
9
|
+
* olLayer: ...,
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
13
|
+
*
|
|
14
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
15
|
+
* @extends {Layer}
|
|
16
|
+
*/
|
|
17
|
+
declare class Layer {
|
|
18
|
+
/**
|
|
19
|
+
* Define layer's properties.
|
|
20
|
+
*
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
defineProperties(options: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the layer and listen to feature clicks.
|
|
26
|
+
* @param {ol/Map~Map} map
|
|
27
|
+
*/
|
|
28
|
+
attachToMap(map: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
31
|
+
*/
|
|
32
|
+
detachFromMap(): void;
|
|
33
|
+
activateUserInteractions(): void;
|
|
34
|
+
singleClickListenerKey: any;
|
|
35
|
+
pointerMoveListenerKey: any;
|
|
36
|
+
deactivateUserInteractions(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private toggleVisibleListeners;
|
|
42
|
+
/**
|
|
43
|
+
* Create a copy of the Layer.
|
|
44
|
+
* @param {Object} newOptions Options to override
|
|
45
|
+
* @return {Layer} A Layer
|
|
46
|
+
*/
|
|
47
|
+
clone(newOptions: any): Layer;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=Layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.js"],"names":[],"mappings":";AAIA;;;;;;;;;;;;;;GAcG;AACH;IAqBE;;;;OAIG;IACH,qCAQC;IAED;;;OAGG;IACH,4BAiDC;IAED;;OAEG;IACH,sBAYC;IAED,iCAyBC;IAjBG,4BAGC;IASD,4BAGC;IAIL,mCAEC;IAED;;;OAGG;IACH,+BAMC;IAED;;;;OAIG;IACH,wBAFY,KAAK,CAIhB;CACF"}
|
package/ol/layers/Layer.js
CHANGED
|
@@ -1,83 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
8
|
+
};
|
|
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];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
var Observable_1 = require("ol/Observable");
|
|
30
|
+
var Layer_1 = require("../../common/layers/Layer");
|
|
31
|
+
var UserInteractionsLayerMixin_1 = require("../../common/mixins/UserInteractionsLayerMixin");
|
|
32
|
+
/**
|
|
33
|
+
* A class representing a layer to display on an OpenLayers map.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { Layer } from 'mobility-toolbox-js/ol';
|
|
37
|
+
*
|
|
38
|
+
* const layer = new Layer({
|
|
39
|
+
* olLayer: ...,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @see <a href="/example/ol-map">Map example</a>
|
|
43
|
+
*
|
|
44
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
45
|
+
* @extends {Layer}
|
|
46
|
+
*/
|
|
47
|
+
var Layer = /** @class */ (function (_super) {
|
|
48
|
+
__extends(Layer, _super);
|
|
49
|
+
/**
|
|
50
|
+
* Constructor.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} options
|
|
53
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
54
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
55
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
56
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
57
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
58
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
59
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
60
|
+
*/
|
|
61
|
+
function Layer(options) {
|
|
62
|
+
var _this = _super.call(this, options) || this;
|
|
63
|
+
if (_this.olLayer) {
|
|
64
|
+
_this.olLayer.setVisible(_this.visible);
|
|
65
|
+
}
|
|
66
|
+
return _this;
|
|
9
67
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!this.map) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (this.olLayer && !this.map?.getLayers()?.getArray()?.includes(this.olLayer)) {
|
|
26
|
-
this.map.addLayer(this.olLayer);
|
|
27
|
-
}
|
|
28
|
-
this.olListenersKeys.push(this.on("change:visible", () => {
|
|
29
|
-
if (this.olLayer) {
|
|
30
|
-
this.olLayer.setVisible(this.visible);
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
this.olListenersKeys.push(this.map.getLayers().on("remove", (evt) => {
|
|
34
|
-
if (evt.element === this.olLayer) {
|
|
35
|
-
this.detachFromMap();
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
|
-
this.toggleVisibleListeners();
|
|
39
|
-
this.olListenersKeys.push(this.on("change:visible", this.toggleVisibleListeners));
|
|
40
|
-
if (this.copyrights && this.olLayer) {
|
|
41
|
-
const attributions = this.copyrights || [];
|
|
42
|
-
if (this.olLayer.getLayers) {
|
|
43
|
-
this.olLayer.getLayers().getArray().forEach((layer) => {
|
|
44
|
-
layer.getSource()?.setAttributions(attributions);
|
|
68
|
+
/**
|
|
69
|
+
* Define layer's properties.
|
|
70
|
+
*
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
Layer.prototype.defineProperties = function (options) {
|
|
74
|
+
_super.prototype.defineProperties.call(this, options);
|
|
75
|
+
Object.defineProperties(this, {
|
|
76
|
+
olLayer: { value: options.olLayer, writable: true },
|
|
77
|
+
olListenersKeys: {
|
|
78
|
+
value: [],
|
|
79
|
+
},
|
|
45
80
|
});
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Initialize the layer and listen to feature clicks.
|
|
84
|
+
* @param {ol/Map~Map} map
|
|
85
|
+
*/
|
|
86
|
+
Layer.prototype.attachToMap = function (map) {
|
|
87
|
+
var _this = this;
|
|
88
|
+
var _a, _b, _c, _d;
|
|
89
|
+
_super.prototype.attachToMap.call(this, map);
|
|
90
|
+
if (!this.map) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (this.olLayer &&
|
|
94
|
+
!((_c = (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getLayers()) === null || _b === void 0 ? void 0 : _b.getArray()) === null || _c === void 0 ? void 0 : _c.includes(this.olLayer))) {
|
|
95
|
+
this.map.addLayer(this.olLayer);
|
|
96
|
+
}
|
|
97
|
+
this.olListenersKeys.push(this.on('change:visible', function () {
|
|
98
|
+
if (_this.olLayer) {
|
|
99
|
+
_this.olLayer.setVisible(_this.visible);
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
this.olListenersKeys.push(this.map.getLayers().on('remove', function (evt) {
|
|
103
|
+
if (evt.element === _this.olLayer) {
|
|
104
|
+
_this.detachFromMap();
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
this.toggleVisibleListeners();
|
|
108
|
+
this.olListenersKeys.push(this.on('change:visible', this.toggleVisibleListeners));
|
|
109
|
+
// We set the copyright to the source used by the layer.
|
|
110
|
+
if (this.copyrights && this.olLayer) {
|
|
111
|
+
var attributions_1 = this.copyrights || [];
|
|
112
|
+
if (this.olLayer.getLayers) {
|
|
113
|
+
this.olLayer
|
|
114
|
+
.getLayers()
|
|
115
|
+
.getArray()
|
|
116
|
+
.forEach(function (layer) {
|
|
117
|
+
var _a;
|
|
118
|
+
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.setAttributions(attributions_1);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (this.olLayer.getSource) {
|
|
122
|
+
(_d = this.olLayer.getSource()) === null || _d === void 0 ? void 0 : _d.setAttributions(attributions_1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
128
|
+
*/
|
|
129
|
+
Layer.prototype.detachFromMap = function () {
|
|
130
|
+
var _a, _b, _c;
|
|
131
|
+
this.deactivateUserInteractions();
|
|
132
|
+
(0, Observable_1.unByKey)(this.olListenersKeys);
|
|
133
|
+
if (this.olLayer &&
|
|
134
|
+
((_c = (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getLayers()) === null || _b === void 0 ? void 0 : _b.getArray()) === null || _c === void 0 ? void 0 : _c.includes(this.olLayer))) {
|
|
135
|
+
this.map.removeLayer(this.olLayer);
|
|
136
|
+
}
|
|
137
|
+
_super.prototype.detachFromMap.call(this);
|
|
138
|
+
};
|
|
139
|
+
Layer.prototype.activateUserInteractions = function () {
|
|
140
|
+
this.deactivateUserInteractions();
|
|
141
|
+
if (this.map &&
|
|
142
|
+
this.userInteractions &&
|
|
143
|
+
this.userClickInteractions &&
|
|
144
|
+
this.userClickCallbacks.length) {
|
|
145
|
+
this.singleClickListenerKey = this.map.on('singleclick', this.onUserClickCallback);
|
|
146
|
+
this.olListenersKeys.push(this.singleClickListenerKey);
|
|
147
|
+
}
|
|
148
|
+
if (this.map &&
|
|
149
|
+
this.userInteractions &&
|
|
150
|
+
this.userHoverInteractions &&
|
|
151
|
+
this.userHoverCallbacks.length) {
|
|
152
|
+
this.pointerMoveListenerKey = this.map.on('pointermove', this.onUserMoveCallback);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
Layer.prototype.deactivateUserInteractions = function () {
|
|
156
|
+
(0, Observable_1.unByKey)([this.pointerMoveListenerKey, this.singleClickListenerKey]);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Toggle listeners needed when a layer is avisible or not.
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
Layer.prototype.toggleVisibleListeners = function () {
|
|
163
|
+
if (this.visible) {
|
|
164
|
+
this.activateUserInteractions();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this.deactivateUserInteractions();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Create a copy of the Layer.
|
|
172
|
+
* @param {Object} newOptions Options to override
|
|
173
|
+
* @return {Layer} A Layer
|
|
174
|
+
*/
|
|
175
|
+
Layer.prototype.clone = function (newOptions) {
|
|
176
|
+
return new Layer(__assign(__assign({}, this.options), newOptions));
|
|
177
|
+
};
|
|
178
|
+
return Layer;
|
|
179
|
+
}((0, UserInteractionsLayerMixin_1.default)(Layer_1.default)));
|
|
180
|
+
exports.default = Layer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class representing Mapboxlayer to display on BasicMap
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import { MapboxLayer } from 'mobility-toolbox-js/ol';
|
|
6
|
+
*
|
|
7
|
+
* const layer = new MapboxLayer({
|
|
8
|
+
* url: 'https://maps.geops.io/styles/travic_v2/style.json',
|
|
9
|
+
* apikey: 'yourApiKey',
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
13
|
+
* @extends {Layer}
|
|
14
|
+
*/
|
|
15
|
+
export default class MapboxLayer extends Layer {
|
|
16
|
+
/**
|
|
17
|
+
* Create the mapbox map.
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
private loadMbMap;
|
|
21
|
+
/** @ignore */
|
|
22
|
+
renderState: {
|
|
23
|
+
center: any[];
|
|
24
|
+
zoom: any;
|
|
25
|
+
rotation: any;
|
|
26
|
+
visible: any;
|
|
27
|
+
opacity: any;
|
|
28
|
+
size: number[];
|
|
29
|
+
};
|
|
30
|
+
/** @ignore */
|
|
31
|
+
copyrights: any[];
|
|
32
|
+
getOlLayerRender(): (frameState: any) => any;
|
|
33
|
+
getMapboxMapClass(): any;
|
|
34
|
+
/**
|
|
35
|
+
* Create a copy of the MapboxLayer.
|
|
36
|
+
* @param {Object} newOptions Options to override
|
|
37
|
+
* @return {MapboxLayer} A MapboxLayer
|
|
38
|
+
*/
|
|
39
|
+
clone(newOptions: any): MapboxLayer;
|
|
40
|
+
}
|
|
41
|
+
import Layer from "./Layer";
|
|
42
|
+
//# sourceMappingURL=MapboxLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapboxLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapboxLayer.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH;IA2BE;;;OAGG;IACH,kBA0CC;IA/BC,cAAc;IACd;;;;;;;MAOC;IAOC,cAAc;IACd,kBAA0D;IAiB9D,6CAEC;IAGD,yBAEC;IAED;;;;OAIG;IACH,wBAFY,WAAW,CAItB;CACF"}
|