mobility-toolbox-js 2.0.0-beta.45 → 2.0.0-beta.47
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 +80 -64
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +58 -45
- package/api/RoutingAPI.d.ts +2 -2
- package/api/RoutingAPI.d.ts.map +1 -1
- package/api/RoutingAPI.js +1 -1
- package/api/StopsAPI.d.ts +14 -12
- package/api/StopsAPI.d.ts.map +1 -1
- package/api/StopsAPI.js +7 -9
- package/api/typedefs.d.ts +84 -10
- package/api/typedefs.d.ts.map +1 -1
- package/api/typedefs.js +3 -1
- package/common/api/WebSocketAPI.d.ts +80 -24
- package/common/api/WebSocketAPI.d.ts.map +1 -1
- package/common/api/WebSocketAPI.js +28 -16
- package/common/controls/{Control.d.ts → ControlCommon.d.ts} +21 -19
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/{Control.js → ControlCommon.js} +21 -8
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +54 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/{mixins/StopFinderMixin.js → controls/StopFinderControlCommon.js} +25 -38
- package/common/layers/{Layer.d.ts → LayerCommon.d.ts} +34 -21
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/{Layer.js → LayerCommon.js} +15 -9
- package/common/mixins/RealtimeLayerMixin.d.ts +243 -19
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +598 -569
- package/common/mixins/UserInteractionsLayerMixin.d.ts +18 -8
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
- package/common/mixins/UserInteractionsLayerMixin.js +170 -159
- package/common/styles/realtimeDefaultStyle.d.ts +30 -9
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
- package/common/styles/realtimeDefaultStyle.js +41 -17
- package/common/styles/realtimeDelayStyle.d.ts +3 -2
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.js +9 -7
- package/common/typedefs.d.ts +64 -3
- package/common/typedefs.d.ts.map +1 -1
- package/common/typedefs.js +34 -4
- package/common/utils/cleanStopTime.d.ts +3 -2
- package/common/utils/cleanStopTime.d.ts.map +1 -1
- package/common/utils/cleanStopTime.js +0 -3
- package/common/utils/compareDepartures.d.ts +6 -4
- package/common/utils/compareDepartures.d.ts.map +1 -1
- package/common/utils/compareDepartures.js +3 -2
- package/common/utils/createCanvas.d.ts +3 -2
- package/common/utils/createCanvas.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.d.ts +3 -2
- package/common/utils/createTrackerFilters.d.ts.map +1 -1
- package/common/utils/createTrackerFilters.js +3 -3
- package/common/utils/getLayersAsFlatArray.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -1
- package/common/utils/getLayersAsFlatArray.js +1 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +13 -3
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -1
- package/common/utils/getMapboxMapCopyrights.js +10 -4
- package/common/utils/getMapboxRender.d.ts +3 -1
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +1 -2
- package/common/utils/getVehiclePosition.d.ts +1 -1
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/removeDuplicate.d.ts +2 -2
- package/common/utils/removeDuplicate.d.ts.map +1 -1
- package/common/utils/renderTrajectories.d.ts +3 -6
- package/common/utils/renderTrajectories.d.ts.map +1 -1
- package/common/utils/renderTrajectories.js +17 -8
- package/common/utils/trackerConfig.d.ts.map +1 -1
- package/common/utils/trackerConfig.js +3 -0
- package/mapbox/controls/CopyrightControl.d.ts +6 -8
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -1
- package/mapbox/controls/CopyrightControl.js +3 -8
- package/mapbox/layers/Layer.js +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
- package/mapbox/utils.d.ts +1 -1
- package/mapbox/utils.d.ts.map +1 -1
- package/mbt.js +825 -703
- package/mbt.js.map +3 -3
- package/mbt.min.js +84 -84
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +10 -10
- package/ol/controls/CopyrightControl.d.ts.map +1 -1
- package/ol/controls/CopyrightControl.js +8 -8
- package/ol/controls/RoutingControl.d.ts +10 -3
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +2 -2
- package/ol/controls/StopFinderControl.d.ts +5 -7
- package/ol/controls/StopFinderControl.d.ts.map +1 -1
- package/ol/controls/StopFinderControl.js +4 -8
- package/ol/layers/Layer.d.ts +57 -9
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/Layer.js +17 -8
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/{common/mixins/MapboxLayerMixin.js → ol/layers/MapGlLayer.js} +66 -44
- package/ol/layers/MapboxLayer.d.ts +15 -17
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +11 -8
- package/ol/layers/MapboxStyleLayer.d.ts +6 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.d.ts +4 -4
- package/ol/layers/MaplibreLayer.d.ts.map +1 -1
- package/ol/layers/MaplibreLayer.js +2 -3
- package/ol/layers/RealtimeLayer.d.ts +106 -30
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +22 -14
- package/ol/styles/fullTrajectoryStyle.d.ts +3 -2
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +15 -9
- package/types/common.d.ts +111 -0
- package/types/index.d.ts +1 -0
- package/types/realtime.d.ts +290 -9
- package/api/RealtimeAPI.test.d.ts +0 -2
- package/api/RealtimeAPI.test.d.ts.map +0 -1
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.d.ts +0 -2
- package/api/RoutingAPI.test.d.ts.map +0 -1
- package/api/RoutingAPI.test.js +0 -29
- package/api/StopsAPI.test.d.ts +0 -2
- package/api/StopsAPI.test.d.ts.map +0 -1
- package/api/StopsAPI.test.js +0 -26
- package/common/api/HttpAPI.test.d.ts +0 -2
- package/common/api/HttpAPI.test.d.ts.map +0 -1
- package/common/api/HttpAPI.test.js +0 -54
- package/common/api/WebSocketAPI.test.d.ts +0 -2
- package/common/api/WebSocketAPI.test.d.ts.map +0 -1
- package/common/api/WebSocketAPI.test.js +0 -380
- package/common/controls/Control.d.ts.map +0 -1
- package/common/controls/Control.test.d.ts +0 -2
- package/common/controls/Control.test.d.ts.map +0 -1
- package/common/controls/Control.test.js +0 -89
- package/common/layers/Layer.d.ts.map +0 -1
- package/common/layers/Layer.test.d.ts +0 -2
- package/common/layers/Layer.test.d.ts.map +0 -1
- package/common/layers/Layer.test.js +0 -137
- package/common/mixins/CopyrightMixin.d.ts +0 -22
- package/common/mixins/CopyrightMixin.d.ts.map +0 -1
- package/common/mixins/CopyrightMixin.js +0 -43
- package/common/mixins/MapboxLayerMixin.d.ts +0 -27
- package/common/mixins/MapboxLayerMixin.d.ts.map +0 -1
- package/common/mixins/StopFinderMixin.d.ts +0 -40
- package/common/mixins/StopFinderMixin.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts +0 -2
- package/common/mixins/UserInteractionsLayerMixin.test.d.ts.map +0 -1
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -214
- package/common/utils/createTrackerFilters.test.d.ts +0 -2
- package/common/utils/createTrackerFilters.test.d.ts.map +0 -1
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.d.ts +0 -2
- package/common/utils/getMapboxMapCopyrights.test.d.ts.map +0 -1
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.d.ts +0 -2
- package/common/utils/removeDuplicate.test.d.ts.map +0 -1
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.d.ts +0 -2
- package/common/utils/timeUtils.test.d.ts.map +0 -1
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.d.ts +0 -2
- package/common/utils/trackerConfig.test.d.ts.map +0 -1
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.d.ts +0 -2
- package/mapbox/layers/Layer.test.d.ts.map +0 -1
- package/mapbox/layers/Layer.test.js +0 -204
- package/mapbox/layers/RealtimeLayer.test.d.ts +0 -2
- package/mapbox/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.d.ts +0 -2
- package/ol/controls/CopyrightControl.test.d.ts.map +0 -1
- package/ol/controls/CopyrightControl.test.js +0 -177
- package/ol/controls/RoutingControl.test.d.ts +0 -2
- package/ol/controls/RoutingControl.test.d.ts.map +0 -1
- package/ol/controls/RoutingControl.test.js +0 -150
- package/ol/controls/StopFinderControl.test.d.ts +0 -2
- package/ol/controls/StopFinderControl.test.d.ts.map +0 -1
- package/ol/controls/StopFinderControl.test.js +0 -49
- package/ol/layers/Layer.test.d.ts +0 -2
- package/ol/layers/Layer.test.d.ts.map +0 -1
- package/ol/layers/Layer.test.js +0 -196
- package/ol/layers/MapboxLayer.test.d.ts +0 -2
- package/ol/layers/MapboxLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxLayer.test.js +0 -164
- package/ol/layers/MapboxStyleLayer.test.d.ts +0 -2
- package/ol/layers/MapboxStyleLayer.test.d.ts.map +0 -1
- package/ol/layers/MapboxStyleLayer.test.js +0 -232
- package/ol/layers/RealtimeLayer.test.d.ts +0 -2
- package/ol/layers/RealtimeLayer.test.d.ts.map +0 -1
- package/ol/layers/RealtimeLayer.test.js +0 -71
- package/ol/layers/RoutingLayer.test.d.ts +0 -2
- package/ol/layers/RoutingLayer.test.d.ts.map +0 -1
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.d.ts +0 -2
- package/ol/layers/VectorLayer.test.d.ts.map +0 -1
- package/ol/layers/VectorLayer.test.js +0 -87
- package/ol/layers/WMSLayer.test.d.ts +0 -2
- package/ol/layers/WMSLayer.test.d.ts.map +0 -1
- package/ol/layers/WMSLayer.test.js +0 -66
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MapEvent } from 'ol';
|
|
2
|
+
import { FrameState } from 'ol/PluggableMap';
|
|
3
|
+
import CopyrightControlCommon from '../../common/controls/CopyrightControlCommon';
|
|
2
4
|
/**
|
|
3
5
|
* Display layer's copyrights.
|
|
4
6
|
*
|
|
@@ -15,17 +17,15 @@ export default CopyrightControl;
|
|
|
15
17
|
*
|
|
16
18
|
* @see <a href="/example/ol-copyright">Openlayers copyright example</a>
|
|
17
19
|
*
|
|
18
|
-
* @extends {
|
|
19
|
-
* @implements {CopyrightInterface}
|
|
20
|
+
* @extends {CopyrightControlCommon}
|
|
20
21
|
*/
|
|
21
|
-
declare class CopyrightControl extends
|
|
22
|
+
declare class CopyrightControl extends CopyrightControlCommon {
|
|
23
|
+
frameState?: FrameState;
|
|
22
24
|
constructor(options: any);
|
|
23
|
-
onPostRender(evt: any): void;
|
|
24
25
|
getCopyrights(): any[];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
frameState: any;
|
|
26
|
+
activate(): void;
|
|
27
|
+
deactivate(): void;
|
|
28
|
+
onPostRender(evt: MapEvent): void;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
export default CopyrightControl;
|
|
31
31
|
//# sourceMappingURL=CopyrightControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyrightControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/CopyrightControl.
|
|
1
|
+
{"version":3,"file":"CopyrightControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/CopyrightControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,sBAAsB,MAAM,8CAA8C,CAAC;AAGlF;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,gBAAiB,SAAQ,sBAAsB;IACnD,UAAU,CAAC,EAAE,UAAU,CAAC;gBAEZ,OAAO,EAAE,GAAG;IAKxB,aAAa;IAyBb,QAAQ;IAOR,UAAU;IAOV,YAAY,CAAC,GAAG,EAAE,QAAQ;CAS3B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { inView } from 'ol/layer/Layer';
|
|
2
|
-
import
|
|
3
|
-
import mixin from '../../common/mixins/CopyrightMixin';
|
|
2
|
+
import CopyrightControlCommon from '../../common/controls/CopyrightControlCommon';
|
|
4
3
|
import removeDuplicate from '../../common/utils/removeDuplicate';
|
|
5
4
|
/**
|
|
6
5
|
* Display layer's copyrights.
|
|
@@ -18,23 +17,24 @@ import removeDuplicate from '../../common/utils/removeDuplicate';
|
|
|
18
17
|
*
|
|
19
18
|
* @see <a href="/example/ol-copyright">Openlayers copyright example</a>
|
|
20
19
|
*
|
|
21
|
-
* @extends {
|
|
22
|
-
* @implements {CopyrightInterface}
|
|
20
|
+
* @extends {CopyrightControlCommon}
|
|
23
21
|
*/
|
|
24
|
-
class CopyrightControl extends
|
|
22
|
+
class CopyrightControl extends CopyrightControlCommon {
|
|
25
23
|
constructor(options) {
|
|
26
24
|
super(options);
|
|
27
25
|
this.onPostRender = this.onPostRender.bind(this);
|
|
28
26
|
}
|
|
29
27
|
getCopyrights() {
|
|
28
|
+
var _a;
|
|
30
29
|
if (!this.frameState) {
|
|
31
30
|
return [];
|
|
32
31
|
}
|
|
33
32
|
let copyrights = [];
|
|
34
33
|
// This code loop comes mainly from ol.
|
|
35
|
-
this.frameState.layerStatesArray.forEach((layerState) => {
|
|
34
|
+
(_a = this.frameState) === null || _a === void 0 ? void 0 : _a.layerStatesArray.forEach((layerState) => {
|
|
36
35
|
const { layer } = layerState;
|
|
37
|
-
if (
|
|
36
|
+
if (this.frameState &&
|
|
37
|
+
inView(layerState, this.frameState.viewState) &&
|
|
38
38
|
layer &&
|
|
39
39
|
layer.getSource &&
|
|
40
40
|
layer.getSource() &&
|
|
@@ -61,7 +61,7 @@ class CopyrightControl extends mixin(Control) {
|
|
|
61
61
|
/**
|
|
62
62
|
* @ignore
|
|
63
63
|
*/
|
|
64
|
-
this.frameState = evt.frameState;
|
|
64
|
+
this.frameState = evt.frameState || undefined;
|
|
65
65
|
this.render();
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -30,7 +30,7 @@ export default RoutingControl;
|
|
|
30
30
|
* @extends {Control}
|
|
31
31
|
* @implements {RoutingInterface}
|
|
32
32
|
*/
|
|
33
|
-
declare class RoutingControl
|
|
33
|
+
declare class RoutingControl implements RoutingInterface {
|
|
34
34
|
/**
|
|
35
35
|
* Calculate at which resolutions corresponds each generalizations.
|
|
36
36
|
*
|
|
@@ -93,7 +93,7 @@ declare class RoutingControl extends Control implements RoutingInterface {
|
|
|
93
93
|
*/
|
|
94
94
|
private onModifyStart;
|
|
95
95
|
/** @ignore */
|
|
96
|
-
apiChangeListener: () => Promise<
|
|
96
|
+
apiChangeListener: () => Promise<void | Feature<import("ol/geom/Geometry").default>> | Promise<Feature<import("ol/geom/Geometry").default> | null> | Promise<any[]> | null;
|
|
97
97
|
/**
|
|
98
98
|
* Adds/Replaces a viaPoint to the viaPoints array and redraws route:
|
|
99
99
|
* Adds a viaPoint at end of array by default.
|
|
@@ -145,6 +145,12 @@ declare class RoutingControl extends Control implements RoutingInterface {
|
|
|
145
145
|
oldRoute: any;
|
|
146
146
|
segmentIndex: number;
|
|
147
147
|
} | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* Define a default element.
|
|
150
|
+
*
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
private createDefaultElement;
|
|
148
154
|
/** @ignore */
|
|
149
155
|
element: HTMLButtonElement | undefined;
|
|
150
156
|
/**
|
|
@@ -169,12 +175,13 @@ declare class RoutingControl extends Control implements RoutingInterface {
|
|
|
169
175
|
* @private
|
|
170
176
|
*/
|
|
171
177
|
private removeListeners;
|
|
178
|
+
activate(): void;
|
|
172
179
|
/** @ignore */
|
|
173
180
|
format: GeoJSON | undefined;
|
|
174
181
|
/** @ignore */
|
|
175
182
|
graphsResolutions: any;
|
|
183
|
+
deactivate(): void;
|
|
176
184
|
}
|
|
177
|
-
import Control from "../../common/controls/Control";
|
|
178
185
|
import { RoutingAPI } from "../../api";
|
|
179
186
|
import { Feature } from "ol";
|
|
180
187
|
import { GeoJSON } from "ol/format";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutingControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/RoutingControl.js"],"names":[],"mappings":";AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,
|
|
1
|
+
{"version":3,"file":"RoutingControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/RoutingControl.js"],"names":[],"mappings":";AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wCAFgB,gBAAgB;IAoH9B;;;;OAIG;IACH,oCAMC;IA5HD,0BA+GC;IAlFC,qDAAqD;IACrD,iBAAoB;IAEpB,cAAc;IACd,YAAgD;IAEhD,cAAc;IACd,SAA+B;IAE/B,cAAc;IACd,gBAAsC;IAEtC,cAAc;IACd,sBAAsD;IAEtD,cAAc;IACd,qBAAuD;IAEvD,cAAc;IACd,0BAAiE;IAEjE,cAAc;IACd,qBAA0B;IAE1B,cAAc;IACd,wBAA0B;IAE1B,cAAc;IACd,YAA4B;IAE5B,cAAc;IACd,iBAAqD;IAErD,cAAc;IACd,gBAAkB;IAElB,cAAc;IACd,iBAA0E;IAE1E,cAAc;IACd,gBAEE;IAEF,cAAc;IACd,kBAKI;IAEJ,cAAc;IACd,kBAUI;IAEJ,cAAc;IACd,iBAAmB;IAoXrB;;;;;OAKG;IACH,mBAeC;IA4CD;;;;;OAKG;IACH,oBAqBC;IArED;;;;OAIG;IACH,sBAmCC;IAxaC,cAAc;IACd,2KAA+C;IAmBjD;;;;;;;;;OASG;IACH,wGAYC;IAED;;;;OAIG;IACH,uBAFW,MAAM,QAYhB;IAED;;;OAGG;IACH,8BAFW,MAAM,MAAM,MAAM,CAAC,CAAC,QAS9B;IAED;;OAEG;IACH,cASC;IAED;;;OAGG;IACH,sBAeC;IAED;;;;;;OAMG;IACH,kBA0HC;IAED;;;;OAIG;IACH,qBAkHC;IA2DC,cAAc;IACd;;;;kBAIC;IAgCH;;;;OAIG;IACH,6BAYC;IAXC,cAAc;IACd,uCAA+C;IAYjD;;;OAGG;IACH,gCA8BC;IA7BC;;;OAGG;IAEH,0BAoBE;IAMJ;;;OAGG;IACH,qBAOC;IAFC,cAAc;IACd,mBAAgE;IAGlE;;;OAGG;IACH,wBAEC;IAED,iBA2BC;IAxBG,cAAc;IACd,4BAEE;IAEF,cAAc;IACd,uBAGC;IAiBL,mBASC;CACF"}
|
|
@@ -8,7 +8,7 @@ import { buffer } from 'ol/extent';
|
|
|
8
8
|
import { fromLonLat, toLonLat } from 'ol/proj';
|
|
9
9
|
import GeomType from 'ol/geom/GeometryType';
|
|
10
10
|
import { RoutingAPI } from '../../api';
|
|
11
|
-
import
|
|
11
|
+
import ControlCommon from '../../common/controls/ControlCommon';
|
|
12
12
|
import RoutingLayer from '../layers/RoutingLayer';
|
|
13
13
|
// Examples for a single hop:
|
|
14
14
|
// basel sbb a station named "basel sbb"
|
|
@@ -71,7 +71,7 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
71
71
|
* @extends {Control}
|
|
72
72
|
* @implements {RoutingInterface}
|
|
73
73
|
*/
|
|
74
|
-
class RoutingControl extends
|
|
74
|
+
class RoutingControl extends ControlCommon {
|
|
75
75
|
constructor(options = {}) {
|
|
76
76
|
super(options);
|
|
77
77
|
Object.defineProperties(this, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Feature } from 'geojson';
|
|
2
|
+
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
2
3
|
/**
|
|
3
4
|
* Search stations.
|
|
4
5
|
*
|
|
@@ -18,15 +19,12 @@ export default StopFinderControl;
|
|
|
18
19
|
*
|
|
19
20
|
*
|
|
20
21
|
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
21
|
-
*
|
|
22
|
-
* @extends {Control}
|
|
23
|
-
* @implements {StopFinderInterface}
|
|
24
22
|
*/
|
|
25
|
-
declare class StopFinderControl extends
|
|
23
|
+
declare class StopFinderControl extends StopFinderControlCommon {
|
|
26
24
|
/**
|
|
27
25
|
* @private
|
|
28
26
|
*/
|
|
29
|
-
|
|
27
|
+
onSuggestionClick(suggestion: Feature): void;
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
export default StopFinderControl;
|
|
32
30
|
//# sourceMappingURL=StopFinderControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StopFinderControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/StopFinderControl.
|
|
1
|
+
{"version":3,"file":"StopFinderControl.d.ts","sourceRoot":"","sources":["../../../src/ol/controls/StopFinderControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAGzC,OAAO,uBAAuB,MAAM,+CAA+C,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAM,iBAAkB,SAAQ,uBAAuB;IACrD;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,OAAO;CAItC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { fromLonLat } from 'ol/proj';
|
|
2
|
-
import
|
|
3
|
-
import mixin from '../../common/mixins/StopFinderMixin';
|
|
2
|
+
import StopFinderControlCommon from '../../common/controls/StopFinderControlCommon';
|
|
4
3
|
/**
|
|
5
4
|
* Search stations.
|
|
6
5
|
*
|
|
@@ -20,16 +19,13 @@ import mixin from '../../common/mixins/StopFinderMixin';
|
|
|
20
19
|
*
|
|
21
20
|
*
|
|
22
21
|
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
23
|
-
*
|
|
24
|
-
* @extends {Control}
|
|
25
|
-
* @implements {StopFinderInterface}
|
|
26
22
|
*/
|
|
27
|
-
class StopFinderControl extends
|
|
23
|
+
class StopFinderControl extends StopFinderControlCommon {
|
|
28
24
|
/**
|
|
29
25
|
* @private
|
|
30
26
|
*/
|
|
31
|
-
onSuggestionClick(
|
|
32
|
-
const coord = fromLonLat(geometry.coordinates);
|
|
27
|
+
onSuggestionClick(suggestion) {
|
|
28
|
+
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
33
29
|
this.map.getView().setCenter(coord);
|
|
34
30
|
}
|
|
35
31
|
}
|
package/ol/layers/Layer.d.ts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { Map } from 'ol';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import LayerGroup from 'ol/layer/Group';
|
|
4
|
+
import OlLayer from 'ol/layer/Layer';
|
|
5
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
6
|
+
import type { AnyMap, UserInteractionCallback } from '../../types';
|
|
7
|
+
export declare type OlLayerOptions = {
|
|
8
|
+
key?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
group?: string;
|
|
11
|
+
copyrights?: string[];
|
|
12
|
+
children?: Layer[];
|
|
13
|
+
visible?: boolean;
|
|
14
|
+
disabled?: Boolean;
|
|
15
|
+
hitTolerance?: Number;
|
|
16
|
+
properties?: {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
};
|
|
19
|
+
map?: AnyMap;
|
|
20
|
+
olLayer: OlLayer | LayerGroup;
|
|
21
|
+
};
|
|
22
|
+
declare const Layer_base: typeof LayerCommon;
|
|
2
23
|
/**
|
|
3
24
|
* A class representing a layer to display on an OpenLayers map.
|
|
4
25
|
*
|
|
@@ -12,38 +33,65 @@ export default Layer;
|
|
|
12
33
|
* @see <a href="/example/ol-map">Map example</a>
|
|
13
34
|
*
|
|
14
35
|
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
15
|
-
* @extends {
|
|
36
|
+
* @extends {LayerCommon}
|
|
16
37
|
*/
|
|
17
|
-
declare class Layer {
|
|
38
|
+
declare class Layer extends Layer_base {
|
|
39
|
+
olLayer?: OlLayer;
|
|
40
|
+
olListenersKeys: EventsKey[];
|
|
41
|
+
options: OlLayerOptions;
|
|
42
|
+
visible: boolean;
|
|
43
|
+
copyrights: string[];
|
|
44
|
+
map?: Map;
|
|
45
|
+
userInteractions?: boolean;
|
|
46
|
+
userClickInteractions?: boolean;
|
|
47
|
+
userHoverInteractions?: boolean;
|
|
48
|
+
userClickCallbacks?: UserInteractionCallback[];
|
|
49
|
+
userHoverCallbacks?: UserInteractionCallback[];
|
|
50
|
+
onUserClickCallback: () => void;
|
|
51
|
+
singleClickListenerKey: EventsKey;
|
|
52
|
+
pointerMoveListenerKey: EventsKey;
|
|
53
|
+
onUserMoveCallback: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Constructor.
|
|
56
|
+
*
|
|
57
|
+
* @param {LayerCommonOptions} options
|
|
58
|
+
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
59
|
+
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
60
|
+
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
61
|
+
* @param {string} [options.copyright=undefined] Copyright-Statement.
|
|
62
|
+
* @param {Array<Layer>} [options.children=[]] Sublayers.
|
|
63
|
+
* @param {Object} [options.properties={}] Application-specific layer properties.
|
|
64
|
+
* @param {boolean} [options.visible=true] If true this layer is the currently visible layer on the map.
|
|
65
|
+
*/
|
|
66
|
+
constructor(options: OlLayerOptions);
|
|
18
67
|
/**
|
|
19
68
|
* Define layer's properties.
|
|
20
69
|
*
|
|
21
70
|
* @ignore
|
|
22
71
|
*/
|
|
23
|
-
defineProperties(options:
|
|
72
|
+
defineProperties(options: OlLayerOptions): void;
|
|
24
73
|
/**
|
|
25
74
|
* Initialize the layer and listen to feature clicks.
|
|
26
75
|
* @param {ol/Map~Map} map
|
|
27
76
|
*/
|
|
28
|
-
attachToMap(map:
|
|
77
|
+
attachToMap(map: Map): void;
|
|
29
78
|
/**
|
|
30
79
|
* Terminate what was initialized in init function. Remove layer, events...
|
|
31
80
|
*/
|
|
32
81
|
detachFromMap(): void;
|
|
33
82
|
activateUserInteractions(): void;
|
|
34
|
-
singleClickListenerKey: any;
|
|
35
|
-
pointerMoveListenerKey: any;
|
|
36
83
|
deactivateUserInteractions(): void;
|
|
37
84
|
/**
|
|
38
85
|
* Toggle listeners needed when a layer is avisible or not.
|
|
39
86
|
* @private
|
|
40
87
|
*/
|
|
41
|
-
|
|
88
|
+
toggleVisibleListeners(): void;
|
|
42
89
|
/**
|
|
43
90
|
* Create a copy of the Layer.
|
|
44
91
|
* @param {Object} newOptions Options to override
|
|
45
92
|
* @return {Layer} A Layer
|
|
46
93
|
*/
|
|
47
|
-
clone(newOptions:
|
|
94
|
+
clone(newOptions: OlLayerOptions): Layer;
|
|
48
95
|
}
|
|
96
|
+
export default Layer;
|
|
49
97
|
//# sourceMappingURL=Layer.d.ts.map
|
package/ol/layers/Layer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.
|
|
1
|
+
{"version":3,"file":"Layer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/Layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,iCAAiC,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEnE,oBAAY,cAAc,GAAG;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B,CAAC;;AAEF;;;;;;;;;;;;;;GAcG;AACH,cAAM,KAAM,SAAQ,UAAkC;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,eAAe,EAAG,SAAS,EAAE,CAAC;IAI9B,OAAO,EAAG,cAAc,CAAC;IAEzB,OAAO,EAAG,OAAO,CAAC;IAElB,UAAU,EAAG,MAAM,EAAE,CAAC;IAEtB,GAAG,CAAC,EAAE,GAAG,CAAC;IAIV,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,kBAAkB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAE/C,mBAAmB,EAAG,MAAM,IAAI,CAAC;IAEjC,sBAAsB,EAAG,SAAS,CAAC;IAEnC,sBAAsB,EAAG,SAAS,CAAC;IAEnC,kBAAkB,EAAG,MAAM,IAAI,CAAC;IAEhC;;;;;;;;;;;OAWG;gBACS,OAAO,EAAE,cAAc;IAQnC;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,cAAc;IAUxC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG;IAyDpB;;OAEG;IACH,aAAa;IAcb,wBAAwB;IA2BxB,0BAA0B;IAI1B;;;OAGG;IACH,sBAAsB;IAQtB;;;;OAIG;IACH,KAAK,CAAC,UAAU,EAAE,cAAc;CAGjC;AACD,eAAe,KAAK,CAAC"}
|
package/ol/layers/Layer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unByKey } from 'ol/Observable';
|
|
2
|
-
import LayerCommon from '../../common/layers/
|
|
2
|
+
import LayerCommon from '../../common/layers/LayerCommon';
|
|
3
3
|
import userInteractionsMixin from '../../common/mixins/UserInteractionsLayerMixin';
|
|
4
4
|
/**
|
|
5
5
|
* A class representing a layer to display on an OpenLayers map.
|
|
@@ -14,13 +14,13 @@ import userInteractionsMixin from '../../common/mixins/UserInteractionsLayerMixi
|
|
|
14
14
|
* @see <a href="/example/ol-map">Map example</a>
|
|
15
15
|
*
|
|
16
16
|
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
17
|
-
* @extends {
|
|
17
|
+
* @extends {LayerCommon}
|
|
18
18
|
*/
|
|
19
19
|
class Layer extends userInteractionsMixin(LayerCommon) {
|
|
20
20
|
/**
|
|
21
21
|
* Constructor.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {LayerCommonOptions} options
|
|
24
24
|
* @param {ol/layer/Layer~Layer} options.olLayer The layer (required).
|
|
25
25
|
* @param {string} [options.name=uuid()] Layer name. Default use a generated uuid.
|
|
26
26
|
* @param {string} [options.key=uuid().toLowerCase()] Layer key, will use options.name.toLowerCase() if not specified.
|
|
@@ -63,7 +63,9 @@ class Layer extends userInteractionsMixin(LayerCommon) {
|
|
|
63
63
|
!((_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))) {
|
|
64
64
|
this.map.addLayer(this.olLayer);
|
|
65
65
|
}
|
|
66
|
-
this.olListenersKeys.push(
|
|
66
|
+
this.olListenersKeys.push(
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
this.on('change:visible', () => {
|
|
67
69
|
if (this.olLayer) {
|
|
68
70
|
this.olLayer.setVisible(this.visible);
|
|
69
71
|
}
|
|
@@ -74,7 +76,9 @@ class Layer extends userInteractionsMixin(LayerCommon) {
|
|
|
74
76
|
}
|
|
75
77
|
}));
|
|
76
78
|
this.toggleVisibleListeners();
|
|
77
|
-
this.olListenersKeys.push(
|
|
79
|
+
this.olListenersKeys.push(
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
this.on('change:visible', this.toggleVisibleListeners));
|
|
78
82
|
// We set the copyright to the source used by the layer.
|
|
79
83
|
if (this.copyrights && this.olLayer) {
|
|
80
84
|
const attributions = this.copyrights || [];
|
|
@@ -84,7 +88,11 @@ class Layer extends userInteractionsMixin(LayerCommon) {
|
|
|
84
88
|
.getArray()
|
|
85
89
|
.forEach((layer) => {
|
|
86
90
|
var _a;
|
|
87
|
-
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
if (layer.getSource) {
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
(_a = layer.getSource()) === null || _a === void 0 ? void 0 : _a.setAttributions(attributions);
|
|
95
|
+
}
|
|
88
96
|
});
|
|
89
97
|
}
|
|
90
98
|
else if (this.olLayer.getSource) {
|
|
@@ -106,18 +114,19 @@ class Layer extends userInteractionsMixin(LayerCommon) {
|
|
|
106
114
|
super.detachFromMap();
|
|
107
115
|
}
|
|
108
116
|
activateUserInteractions() {
|
|
117
|
+
var _a, _b;
|
|
109
118
|
this.deactivateUserInteractions();
|
|
110
119
|
if (this.map &&
|
|
111
120
|
this.userInteractions &&
|
|
112
121
|
this.userClickInteractions &&
|
|
113
|
-
this.userClickCallbacks.length) {
|
|
122
|
+
((_a = this.userClickCallbacks) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
114
123
|
this.singleClickListenerKey = this.map.on('singleclick', this.onUserClickCallback);
|
|
115
124
|
this.olListenersKeys.push(this.singleClickListenerKey);
|
|
116
125
|
}
|
|
117
126
|
if (this.map &&
|
|
118
127
|
this.userInteractions &&
|
|
119
128
|
this.userHoverInteractions &&
|
|
120
|
-
this.userHoverCallbacks.length) {
|
|
129
|
+
((_b = this.userHoverCallbacks) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
121
130
|
this.pointerMoveListenerKey = this.map.on('pointermove', this.onUserMoveCallback);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="mapbox-gl" />
|
|
2
|
+
import { RenderFunction } from 'ol/layer/Layer';
|
|
3
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
4
|
+
import OlMap from 'ol/Map';
|
|
5
|
+
import { Coordinate } from 'ol/coordinate';
|
|
6
|
+
import { AnyMapboxMap, AnyMapboxMapClass, LayerGetFeatureInfoResponse } from '../../types';
|
|
7
|
+
import Layer, { OlLayerOptions } from './Layer';
|
|
8
|
+
export declare type MapGlLayerOptions = OlLayerOptions & {
|
|
9
|
+
url?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
apiKeyName?: string;
|
|
12
|
+
mapOptions?: any;
|
|
13
|
+
tabIndex?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Common class for Mapbox and Maplibre and potential other fork from Mapbox.
|
|
17
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs.
|
|
18
|
+
*/
|
|
19
|
+
declare class MapGlLayer extends Layer {
|
|
20
|
+
mbMap?: AnyMapboxMap;
|
|
21
|
+
styleUrl?: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
apiKeyName: string;
|
|
24
|
+
format: GeoJSON;
|
|
25
|
+
loaded: boolean;
|
|
26
|
+
options: MapGlLayerOptions;
|
|
27
|
+
constructor(options: MapGlLayerOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Initialize the layer and listen to feature clicks.
|
|
30
|
+
* @param {ol/Map~Map} map
|
|
31
|
+
*/
|
|
32
|
+
attachToMap(map: OlMap): void;
|
|
33
|
+
/**
|
|
34
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
35
|
+
*/
|
|
36
|
+
detachFromMap(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Create the mapbox map.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
loadMbMap(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Update attributions of the source.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
updateAttribution(evt: maplibregl.MapLibreEvent | mapboxgl.MapboxEvent): void;
|
|
47
|
+
/**
|
|
48
|
+
* Request feature information for a given coordinate.
|
|
49
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
50
|
+
* @param {Object} options A [mapboxgl.Map#queryrenderedfeatures](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#queryrenderedfeatures) options parameter.
|
|
51
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate. The original Mapbox feature is available as a property named 'mapboxFeature'.
|
|
52
|
+
*/
|
|
53
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate, options: any): Promise<LayerGetFeatureInfoResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Return the render function function for the ol layer.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
getOlLayerRender(): RenderFunction;
|
|
59
|
+
/**
|
|
60
|
+
* Return the Class to instanciate for the mapbox map.
|
|
61
|
+
*
|
|
62
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
63
|
+
*/
|
|
64
|
+
getMapboxMapClass(): AnyMapboxMapClass;
|
|
65
|
+
}
|
|
66
|
+
export default MapGlLayer;
|
|
67
|
+
//# sourceMappingURL=MapGlLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapGlLayer.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/MapGlLayer.ts"],"names":[],"mappings":";AAEA,OAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhD,oBAAY,iBAAiB,GAAG,cAAc,GAAG;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,cAAM,UAAW,SAAQ,KAAK;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,UAAU,EAAG,MAAM,CAAC;IAEpB,MAAM,EAAG,OAAO,CAAC;IAEjB,MAAM,EAAG,OAAO,CAAC;IAEjB,OAAO,EAAG,iBAAiB,CAAC;gBAEhB,OAAO,EAAE,iBAAiB;IAmCtC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,KAAK;IAkBtB;;OAEG;IACH,aAAa;IAab;;;OAGG;IACH,SAAS;IA2ET;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW;IAQtE;;;;;OAKG;IACH,0BAA0B,CACxB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,2BAA2B,CAAC;IAqDvC;;;OAGG;IAEH,gBAAgB,IAAI,cAAc;IAOlC;;;;OAIG;IAEH,iBAAiB,IAAI,iBAAiB;CAMvC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
/* eslint-disable max-classes-per-file */
|
|
2
2
|
import { toLonLat } from 'ol/proj';
|
|
3
|
-
import
|
|
3
|
+
import OlLayer from 'ol/layer/Layer';
|
|
4
4
|
import Source from 'ol/source/Source';
|
|
5
5
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
6
|
-
import { getUrlWithParams, getMapboxMapCopyrights } from '
|
|
6
|
+
import { getUrlWithParams, getMapboxMapCopyrights } from '../../common/utils';
|
|
7
|
+
import Layer from './Layer';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Common class for Mapbox and Maplibre and potential other fork from Mapbox.
|
|
10
|
+
* It's used to share code between Mapbox and Maplibre layers without importing both libs.
|
|
9
11
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* Return the render function function for the ol layer.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line class-methods-use-this
|
|
16
|
-
getOlLayerRender() { }
|
|
17
|
-
/**
|
|
18
|
-
* Return the Class to instanciate for the mapbox map.
|
|
19
|
-
*
|
|
20
|
-
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
21
|
-
*/
|
|
22
|
-
// eslint-disable-next-line class-methods-use-this
|
|
23
|
-
getMapboxMapClass() { }
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Mixin for MapboxLayerLayerInterface.
|
|
27
|
-
* It's used to share code between Mapbox and Maplibre layers without importing both libs
|
|
28
|
-
*
|
|
29
|
-
* @param {Class} Base A class to extend with {MapboxLayerLayerInterface} functionnalities.
|
|
30
|
-
* @return {Class} A class that implements {MapboxLayerLayerInterface} class and extends Base;
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
const MapboxLayerMixin = (Base) => class extends Base {
|
|
34
|
-
constructor(options = {}) {
|
|
12
|
+
class MapGlLayer extends Layer {
|
|
13
|
+
constructor(options) {
|
|
35
14
|
super(options);
|
|
36
|
-
this.olLayer = new
|
|
15
|
+
this.olLayer = new OlLayer({
|
|
37
16
|
source: new Source({}),
|
|
38
|
-
render: this.getOlLayerRender(
|
|
17
|
+
render: this.getOlLayerRender(),
|
|
39
18
|
});
|
|
40
19
|
/**
|
|
41
20
|
* Url of the mapbox style.
|
|
@@ -88,7 +67,7 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
88
67
|
// to avoid display of errors we set an empty function.
|
|
89
68
|
this.mbMap.triggerRepaint = () => { };
|
|
90
69
|
this.mbMap.remove();
|
|
91
|
-
this.mbMap =
|
|
70
|
+
this.mbMap = undefined;
|
|
92
71
|
}
|
|
93
72
|
this.loaded = false;
|
|
94
73
|
super.detachFromMap();
|
|
@@ -98,15 +77,20 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
98
77
|
* @private
|
|
99
78
|
*/
|
|
100
79
|
loadMbMap() {
|
|
101
|
-
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
this.olListenersKeys.push(
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('change:target', () => {
|
|
102
84
|
this.loadMbMap();
|
|
103
85
|
}));
|
|
104
|
-
if (!this.map.getTargetElement()) {
|
|
86
|
+
if (!((_b = this.map) === null || _b === void 0 ? void 0 : _b.getTargetElement())) {
|
|
105
87
|
return;
|
|
106
88
|
}
|
|
107
89
|
if (!this.visible) {
|
|
108
90
|
// On next change of visibility we load the map
|
|
109
|
-
this.olListenersKeys.push(
|
|
91
|
+
this.olListenersKeys.push(
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
this.once('change:visible', () => {
|
|
110
94
|
this.loadMbMap();
|
|
111
95
|
}));
|
|
112
96
|
return;
|
|
@@ -115,7 +99,12 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
115
99
|
container.style.position = 'absolute';
|
|
116
100
|
container.style.width = '100%';
|
|
117
101
|
container.style.height = '100%';
|
|
118
|
-
if (!this.
|
|
102
|
+
if (!this.styleUrl) {
|
|
103
|
+
// eslint-disable-next-line no-console
|
|
104
|
+
console.error(`No styleUrl defined for mapbox layer: ${this.styleUrl}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!this.apiKey && !((_c = this.styleUrl) === null || _c === void 0 ? void 0 : _c.includes(this.apiKeyName))) {
|
|
119
108
|
// eslint-disable-next-line no-console
|
|
120
109
|
console.error(`No apiKey defined for mapbox layer with style url to ${this.styleUrl}`);
|
|
121
110
|
}
|
|
@@ -133,6 +122,7 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
133
122
|
* @type {boolean}
|
|
134
123
|
*/
|
|
135
124
|
this.loaded = true;
|
|
125
|
+
// @ts-ignore
|
|
136
126
|
this.dispatchEvent({
|
|
137
127
|
type: 'load',
|
|
138
128
|
target: this,
|
|
@@ -145,11 +135,11 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
145
135
|
* @private
|
|
146
136
|
*/
|
|
147
137
|
updateAttribution(evt) {
|
|
148
|
-
var _a, _b;
|
|
138
|
+
var _a, _b, _c;
|
|
149
139
|
const newAttributions = getMapboxMapCopyrights(evt.target) || [];
|
|
150
140
|
if (((_a = this.copyrights) === null || _a === void 0 ? void 0 : _a.toString()) !== newAttributions.toString()) {
|
|
151
141
|
this.copyrights = newAttributions;
|
|
152
|
-
(_b = this.olLayer.getSource()) === null ||
|
|
142
|
+
(_c = (_b = this.olLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.setAttributions(newAttributions);
|
|
153
143
|
}
|
|
154
144
|
}
|
|
155
145
|
/**
|
|
@@ -166,18 +156,27 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
166
156
|
!this.mbMap.isStyleLoaded()) {
|
|
167
157
|
return Promise.resolve({ coordinate, features: [], layer: this });
|
|
168
158
|
}
|
|
169
|
-
|
|
159
|
+
const pixel = coordinate &&
|
|
160
|
+
this.mbMap.project(toLonLat(coordinate));
|
|
161
|
+
let pixels;
|
|
170
162
|
if (this.hitTolerance) {
|
|
171
163
|
const { x, y } = pixel;
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
|
|
164
|
+
pixels = [
|
|
165
|
+
{
|
|
166
|
+
x: x - this.hitTolerance,
|
|
167
|
+
y: y - this.hitTolerance,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
x: x + this.hitTolerance,
|
|
171
|
+
y: y + this.hitTolerance,
|
|
172
|
+
},
|
|
175
173
|
];
|
|
176
174
|
}
|
|
177
175
|
// At this point we get GeoJSON Mapbox feature, we transform it to an OpenLayers
|
|
178
176
|
// feature to be consistent with other layers.
|
|
179
177
|
const features = this.mbMap
|
|
180
|
-
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
.queryRenderedFeatures(pixels || pixel, options)
|
|
181
180
|
.map((feature) => {
|
|
182
181
|
const olFeature = this.format.readFeature(feature);
|
|
183
182
|
if (olFeature) {
|
|
@@ -194,5 +193,28 @@ const MapboxLayerMixin = (Base) => class extends Base {
|
|
|
194
193
|
coordinate,
|
|
195
194
|
});
|
|
196
195
|
}
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Return the render function function for the ol layer.
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
// eslint-disable-next-line class-methods-use-this
|
|
201
|
+
getOlLayerRender() {
|
|
202
|
+
// eslint-disable-next-line no-console
|
|
203
|
+
console.error('This function must be implemented in subclasses');
|
|
204
|
+
const div = document.createElement('div');
|
|
205
|
+
return () => div;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Return the Class to instanciate for the mapbox map.
|
|
209
|
+
*
|
|
210
|
+
* @return {mapboxgl.Map|maplibregl.Map} map
|
|
211
|
+
*/
|
|
212
|
+
// eslint-disable-next-line class-methods-use-this
|
|
213
|
+
getMapboxMapClass() {
|
|
214
|
+
// eslint-disable-next-line no-console
|
|
215
|
+
console.error('This function must be implemented in subclasses');
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export default MapGlLayer;
|